When $X$ is compact, it is discrete (hence not compact unless it is finite). For any function $f:X \to \{0,1\}$, then both $K_0 = f^{-1}(0)$ and $K_1=f^{-1}(1)$ are compact subset of $X$, and so the set
$$ \{f\} = \{g | g(K_1) = \{1\}\} \cap \{g | g(K_0) = \{0\}\} $$
is open.
If $X$ is only assumed to be locally compact, then $C(X,\{0,1\})$ is in general not locally compact.
For example take $X$ to be a countable union of copies of the Cantor space
$$X= \coprod_{n \in \mathbb{N}} K$$.
Then one can show that $C(X,\{0,1\}) = \prod_{n\in \mathbb{N}} C(K,\{0,1\})$ with the product topology. As a product of an infinite familly of discrete and inifinite sets, it is homoemorphic to $\mathbb{N}^\mathbb{N}$ so, not locally compact.
In fact:
Theorem: assuming $X$ is locally compact and zero-dimensional (It has a basis of clopen), then $C(X,2)$ is locally compact if and only if $X$ is the disjoint union of a compact and a discrete set.
The "zero-dimensional" is very natural as $C(X,2)$ only sees the clopen of $X$ anyway (and it obviously can't be removed as this construction would not see any feature of a connected space for example)
Proof: if $ X = K \coprod D$ is the union of a compact and a discrete part then
$$C(X,2) = C(K,2) \times C(D,2) = C(K,2) \times 2^D$$
So it is a product of a compact by a discrete sets, and hence is locally compact.
Conversely, assume that $C(X,2)$ is locally compact. Let $f$ be any element of $C(X,2)$ and consider $W$ a compact neighbourhood of $f$.
A basis of the topology of $C(X,2)$ is given by the set of the form
$$\{f | f(K_1) =1 ; f(K_0) =0 \}$$
for $K_1$ and $K_2$ two open compact subsets of $X$. The reason we can restrict to open compact is because for any compact $K$
$$\{g | g(K) =0\} = \bigcup_{K \subset E} \{g| g(E)=0\}$$
where the union run over open compact $E$ only.
So we know there are two open compact subset $K_1,K_2 \subset X$ such that
$$ f \in \{g | g(K_1) =1 ; g(K_0) =0 \} \subseteq W $$
Let $K= K_1 \cup K_0$ (which is also compact and open) it follows that any function $h$ such that $h|_K = f|_K$ is in $W$.
Let $x$ be any point of $X$ not in $K$. We will show that $\{x\}$ is open which conclude the proofs as it shows that the topology of $X$ is $K$ \coprod $X - K$ with the discrete topology on $X-K$.
Let $V$ be a compact neighbourhood of $x$ disjoint from $K$. AS $V$,$K$ and $R = X-V-K$ form a partition of $X$ in three clopen, we have that $C(X,2) = C(K,2) \times C(V,2) \times C(R,2)$. So,
$$D = \{f|_K\} \times C(V,2) \times \{0\} \subset C(K,2) \times C(V,2) \times C(R,2) $$
Then $D$ is a closed subspace of $X$ homeomorphic to $C(V,2)$, hence discrete. But, for any $h \in D$, $h|_K = f|_K$, so $D \subset W$. So $D$ it is compact and discrete, so finite.
This shows that $C(V,2)$ is finite. So by Stone duality, $V$ is finite and discrete. It follows that $\{x\}$ is open.