Topological spaces whose continuous image is always closed
If $Z$ is not compact, and $X=\{p\}\cup Z$ is the space whose nonempty open sets are of the form $\{p\}\cup V$ with $V$ open in $Z$, then $X$ is not compact, but every continuous function from $X$ to a Hausdorff space is constant.
No: if $X$ is non compact, it is a proper and dense subset, thus not closed, in its Stone–Čech compactification.
[edit] This is ok e.g. if X is $T_{3.5}$, as Bruno observes, otherwise $X\to\beta X$ may be surjective (I tend to culpably remove from my conscience the existence of less-separated topological spaces). So, given that a non-compact $T_{3.5}$ space is a proper subspace of its SC compactification, a suitable statement is "compact equals universally closed for $T_{3.5}$ spaces ", and analogous statements may be sought for other categories of topological spaces. In any case, it does not seem very fair, in the definition of "universally closed", to ask for more separation in $Y$ than in $X$ as you are doing. As in Jonas Meyer's answer: for instance, let's consider $X= \mathbb{Z} ,$ with left-unbounded order intervals as open sets. Then every two non-empty closed sets have non-empty intersection, so any continuous map $f:X\to Y$ to a Hausdorff space $Y$ is constant, thus $X$ is $T_0$, non-compact but universally closed in the definition you gave).
I believe the question whether $X$ can be chosen to be Hausdorff was left open by both existing answers. The solution is provided by the H-closed spaces of Henno Brandsma's comment. I shall answer the question from that comment in the positive.
Proposition. A Hausdorff space $X$ is H-closed iff it is universally closed.
Proof. The "if" direction is trivial.
To prove "only if", we use the well-known fact that a Hausdorff space is H-closed iff every open cover of $X$ contains a finite collection of sets whose closures cover $X$. (See the Wikipedia page cited above, or the section on H-closed spaces in Extensions and Absolutes of Hausdorff Spaces by Jack R. Porter and R. Grant Woods.)
So suppose $f\colon X\to Y$ is continuous, where $Y$ is Hausdorff, and let $y\in Y\setminus f(X)$. Since $Y$ is Hausdorff, for every $x\in X$ there is a closed neighbourhood $U[x]\subset Y$ of $f(x)$ not containing $y$. Since $X$ is H-closed, there is a finite collection $x_1,\dots,x_k$ such that $$ X = \bigcup_i f^{-1}(U[x_i]). $$ So $$ y\in Y\setminus \bigcup_i U[x_i] \subset Y\setminus f(X), $$ and hence $Y\setminus f(X)$ is a neighbourhood of $y$. So $f(X)$ is closed, as claimed. $\blacksquare$
Alternatively, you may consider directly the following simple example of a H-closed space from Porter-Woods. This space is given by $$ X := \{p^-,p^+\} \cup \{(1/n,1/m)\colon n\in\mathbb{N}, m\in\mathbb{Z}\setminus\{0\}\} \cup \{(1/n,0)\colon n\in\mathbb{N}\}.$$ $Y:=X\setminus\{p^-,p^+\}$ has the usual topology induced from $\mathbb{R}^2$, while a neighbourhood of $p^+$ (resp. $p^-$) should contain all points $(1/n,1/m)$ with sufficiently large $n$ and positive (resp. negative) $m$.
It is easy to verify directly that this space is universally closed (and H-closed).
As noted in Pietro's answer, the map from a universally closed space to its Stone-Cech compactification is surjective. The question remains whether there is a space with the latter property which is not H-closed.