A retract is a subspace $R\subseteq X$ for which there exists a continuous map $f:X\to R$ with $f(r)=r$ for all $r\in R$.
If $X$ is compact and has the property KC (all compacts are closed, a weakening of $T_2$), then every retract is compact and therefore closed.
Can KC be weakened to weakly Hausdorff here? Note that the one-point compactification of the Arens square space shows that KC cannot be weakened as far as US.
No. The square of the one-point compactification of the rationals is compact and weakly Hausdroff, but its diagonal is a retract (by $(p,q)\mapsto(q,q)$) that is not closed in the space.
More generally, the square of any compact, weakly Hausdorff, non-$T_2$ space is compact and weakly Hausdorff, but has a non-closed diagonal which is a compact retract.