Here’s an approach using closed sets.
$(\rightarrow)$
Assume by contradiction that $A$ is infinite but $f(A)$ is finite. Then $f(A)$ is closed; since $f$ is continuous, $f^{-1}(f(A))$ is closed. Therefore, $f^{-1}(f(A))$ is either finite or all of $X$. If it is finite, then $A\subseteq f^{-1}(f(A))$ implies $A$ is finite, a contradiction.
Now suppose $f^{-1}(f(A))=X$. Suppose $V\subseteq f(A)$. Since $V$ is finite, $V$ is closed. But $f^{-1}(f(A)-V) = f^{-1}(f(A))-f^{-1}(V)$, so $f^{-1}(V)$ must either be $\varnothing$ or $X$. Therefore, there exists a singleton $\{y\}$ such that $f^{-1}(y)=X$, contradicting the assumption that $f$ is not constant. As such, $f^{-1}$ cannot be continuous, as desired.
$(\leftarrow)$
Let $V\ne X$ be a closed set of $X$. Then $V$ is finite, so if $f^{-1}(V)$ was infinite, then $f(f^{-1}(V))\subseteq V$ would be infinite by assumption, a contradiction. Clearly $f^{-1}(X)$ is closed, so the proof is complete.
EDIT: Here is some more justification for the $f^{-1}(f(A)) = X$ case.
Recall we assumed the existence of an infinite set $A\subseteq X$, so $X$ is infinite. Because $V$ is closed, $f^{-1}(V)$ is closed. $f(A)-V$ is also closed because $f(A)$ is finite, so
$$f^{-1}(f(A)-V) = f^{-1}(f(A))-f^{-1}(V) = X - f^{-1}(V)$$
is also closed. $f^{-1}(V)$ can either be $\varnothing$, a finite set, or $X$ itself. If $f^{-1}(V)$ is finite and not empty, then $X-f^{-1}(V)\ne X$ is closed, impossible because it is an infinite set.
Hence for all singletons $y\in f(A)$, $f^{-1}(y) = X$ or $f^{-1}(y)=\varnothing$. If all of the fibers $f^{-1}(y)=\varnothing$, then
$$f^{-1}(f(A)) = f^{-1}\left(\bigcup_{y\in f(A)} y\right) =\bigcup_{y\in f(A)} f^{-1}(y)= \varnothing,$$
a contradiction.
I do not think there is a simpler way to prove this exercise, and the reason is that the conclusion of this exercise implies (and is hence equivalent to) Sierpiński's result.
In other words, if, contrary to Sierpiński, we have a nontrivial decomposition of $[0,1]$ into disjoint closed sets $\{A_i\}$ then we may define $f\colon [0,1]\to \mathbb N$ by $f(x)=i$ for $x\in A_i$. Then the inverse image of every finite set is closed, hence $f$ is a continuous and nonconstant map, contradicting the conclusion of the exercise.
Therefore a simple proof for the exercise would give a simple proof for Sierpiński's theorem itself.
Best Answer
If $f$ is not constant it has at least two values, say $p$ and $q$ in the reals. We can find two disjoint open intervals $I=(p-r,p+r)$ and $I'=(q-r,q+r)$ in the reals that are disjoint (for small enough $r$), and then by continuity of $f$, both $O=f^{-1}[I]$ and $O' = f^{-1}[I']$ are disjoint non-empty (as $p$ and $q$ are assumed values) open sets in $X$.
But such open sets cannot exist: $O=X\setminus F$ for some finite set $F$ and $O' = X\setminus F'$ for some finite set $F'$. Any point in $X \setminus (F \cup F')$, which must exist as the union of two finite sets is finite and $X$ is infinite, is in both $O$ and $O'$, so non-empty open sets in $X$ (in the cofinite topology) always intersect. This property is called hyperconnected, FYI.
So any continuous map from a hyperconnected space to a Hausdorff space is constant, is what the previous proof shows.