How do I prove that there exists a countable subset excluding two points?

Let $X$ be a compact connected metric space.

Let $a,b$ be distinct points in $X$.

How do I prove that there exists a countable dense subset $D$ of $X$ which contains neither $a$ nor $b$?

Since $X$ is a compact metric space, it is obviously separable. However, I think connectedness should be used to derive that there exists such $D$ not containing two points. How do I prove it ?

You can cover X with a finite number $l(n)$ of open balls $B(x_1,\frac{1}{n}),...,B(x_{l(n)},\frac{1}{n})$, $n$ is an integer $>0$. In each ball $B(x_i,\frac{1}{n})$, take an element $u^i_n$ distinct from $a$ and $b$; this element exists since $X$ is connected, the countable set $u^i_n$ is dense in $X$.
Use connectedness to show that for any $n$ there exists $a_n \neq a$ belonging to ball centered at $a$ and radius $\frac 1n$. Define $b_n$ analogously.
As you noticed, $X$ is separable thus there exists a countable set $S$ which is dense in $X$.
Then set $S \cup \{a_n : n\in \mathbb N\} \cup \{b_n : n \in \mathbb N\} \setminus \{a,b\}$ is countable and dense in $X$ and contains neither $a$ nor $b$.