No, not even, if X is a subset of the plane.
Recall that a topological space is widely connected, if
$X$ is connected and
each connected subset with more than one point is dense in the space.
According to a famous paper of P.N. Swingle from 1931 (!), there is a (non-trivial) $X \subset \mathbb{R}^2$, which is widely connected.
Since $X$ is Hausdorff, pick non-empty $U, V$ open in $X$ such that $U \cap V = \emptyset$.
Then $X = A \cup B$ with $ A := X \setminus U$, $B := X \setminus V$.
Of course, $A, B$ are closed in $X$.
Assume $A$ is not totally disconnected.
Let $C \subset A$ be connected with more than one point.
Then $C$ is dense in $X$, hence A is dense in $X$, hence
$A \cap (X \setminus A) = A \cap U \neq \emptyset$.
Contradiction! Hence, $A$ is totally disconnected.
Analogously, $B$ is totally disconnected.
(There might be less difficult examples for spaces with low separation.)