This question is a special case of Dominic van der Zypen's question Reconstructing relations with the image relation of a topology, as discussed in the comments, particularly the comment of Eric Wofsey, which explains that if the answer to this question is affirmative, then the answer to Dominic's question is also affirmative.
Question. Does every set $X$ have a topology for which the only continuous surjection $f:X\to X$ is the identity map?
My answer to Dominic's question shows that for finite sets, the answer is affirmative, since one need only place an order on $X$, and then let the topology be the up-sets of the order. Every continuous surjection is a permutation of $X$ and order-preserving, and hence the identity. Although it is tempting to try to use the same method with well-orders on an infinite set, it doesn't quite work out in that generality, because the predecessor function on the finite height elements (otherwise fixed) will be a continuous surjection, but not the identity.
For an extreme negative answer, I would ask: can one show that there is no topology on a countably infinite set for which the only continuous surjection is the identity map?