Let $A:=\{(x_1,x_2) \in X \times X\,|\,f(x_1)=f(x_2)\}$. We will show that $(X \times X)\setminus A =\{(x_1,x_2) \in X \times X\,|\,f(x_1) \ne f(x_2)\}$ is open. Since $f(x_1) \ne f(x_2)$, there are disjoint open sets $U \ni f(x_1)$ and $V \ni f(x_2)$ by the fact that $Y$ is $T_2$. Since $f$ is continuous, there are open sets $O_1 \ni x_1$ and $O_2 \ni x_2$ in $X$, such that $f[O_1] \subset U$ and $f[O_2] \subset V$. Then $O_1 \times O_2$ is an open set containing $(x_1,x_2)$ in the product topology on $X \times X$. When $(x,y)$ is in $O_1 \times O_2$, then $f(x) \in U, f(y) \in V$, so $f(x) \neq f(y)$, as $U$ and $V$ are disjoint, which shows that $O_1 \times O_2 \subset (X \times X) \setminus A$, so that $(X \times X)\setminus A$ is the union of such open sets, and so is open itself. It follows that $A$ is closed.
Here's a proof using the idea in Qiaochu's comment:
Let $A:=\{(x_1,x_2)\in X \times X\,|\,f(x_1)=f(x_2)\}$ and consider the map $(f,f):X \times X \to Y \times Y$. Since $Y$ is $T_2$, $\Delta_Y$ is closed (I do understand the proof of this). Since if $(x_1,x_2) \in A$ then $f(x_1)=f(x_2)$, it follows that $(f,f)(A) \subseteq \Delta_Y$. Then $(f,f)^{-1}(\Delta_Y)=A$, and since $f$ is continuous then $(f,f)$ is continuous and it follows that $A$ is closed.