This question already gives much of the answer: when $X$ is finite, certainly $C(X)$ is finite-dimensional, since $C(X)$ is just $\mathbb{R}^X$.
Let the metric on $X$ be $d$.
When $X$ is infinite, we can choose a sequence of finite increasing subsets $\{S_j\}_j$ where $S_j\subseteq X$ and $|S_j|=j$. We have the natural projection $\pi_j\in C(X)\to C(S_j)$ given by "evaluation at $S_j$". Also, for each $s\in S_j$, the function $x\mapsto d(s,x)$ is a function that is zero on precisely $\{s\}$. Taking products, we can construct functions that are zero on precisely all-but-one-point of $S_j$, and then sum to get any function on $S_j$. Thus $\pi_j$ is always surjective. Moreover, define the function $g_j(x)=\prod_{s\in S_j}{d(s,x)}$; we have $\pi_j(g_j)=0$.
Suppose $C(X)$ has dimension $J$. Then $C(S_J)$ also has dimension $J$, and so $\pi_J$ is injective. Thus $g_J=0$. But since $X$ is infinite, there exists $y\in X\setminus S_J$. By the definition of a metric, we can prove each factor in $g$ is nonzero, though, and so $g(y)>0$. $\rightarrow\leftarrow$.