This is true for compact Hausdorff spaces. More generally, if $X$ is a compact Hausdorff space and $Y$ is any space, then every ring-homomorphism $C(X)\to C(Y)$ is given by composition with a continuous map $Y\to X$. To prove this, note first that every homomorphism $C(X)\to\mathbb{R}$ is of the form $f\mapsto f(x)$ for some $x\in X$ (see here for a proof). Let $e_x$ denote the evaluation at $x$ homomorphism $f\mapsto f(x)$. Now if $G:C(X)\to C(Y)$ is a homomorphism, for each $y\in Y$, the composition $e_y\circ G$ is equal to $e_x$ for some $x\in X$; let $F(y)$ be this $x$, so $F$ is a function $Y\to X$. For any $f\in C(X)$ and any $y\in Y$, then, $G(f)(y)=e_y(G(f))=e_{F(y)}(f)=f(F(y))$, so $G$ is given by composition with $F$. It follows that $F$ is continuous (since its composition with each element of $C(X)$ is continuous and $X$ is completely regular).
In general, a Tychonoff space is called realcompact if every homomorphism $C(X)\to\mathbb{R}$ is given by evaluation at a point of $X$. The same argument as above shows that if $X$ is realcompact then every homomorphism $C(X)\to C(Y)$ is given by composition with a continuous map, and in particular then every automorphism of $C(X)$ is given by composition with a homeomorphism $X\to X$.
This conclusion about automorphisms is not true for arbitrary Tychonoff spaces. For a counterexample, let $X=((\omega_1+1)\times\{0,1\})\setminus\{(\omega_1,1)\}$. Since every continuous real-valued function on $\omega_1$ is eventually constant (and so extends continuously to $\omega_1+1$), $C(X)\cong C((\omega_1+1)\times\{0,1\})$. Now $(\omega_1+1)\times\{0,1\}$ has an automorphism that swaps $0$ and $1$ on the second coordinate, and this gives an automorphism of $C(X)$. However, this automorphism of $C(X)$ does not come from any automorphism of $X$, since it sends the homomorphism $C(X)\to\mathbb{R}$ given by evaluation at the point $(\omega_1,0)$ to a homomorphism $C(X)\to\mathbb{R}$ which is not given by evaluation at any point (it would be evaluation at $(\omega_1,1)$ but that point is not in $X$).