We shall prove the slightly more general
Theorem. For a locally compact Hausdorff space $X$ the following are equivalent:
(1) $X$ is locally connected and has only finitey many components.
(2) For each compact subset $K \subset X$ and each open set $U \subset X$ containing $K$, all but finitely many components of $X \setminus K$ are contained in $U$.
Remark: A locally compact Hausdorff space $X$ which is locally connected and connected may have compact subsets $K$ such that $X \setminus K$ has infinitely many components. An example is $X = [0,1] \subset \mathbb R$ which is compact Hausdorff, locally connected and connected. Now consider $K = \{0\} \cup \{ 1/n \mid n \in \mathbb N \}$.
Let us prepare the proof of the theorem by a definition and a lemma.
A splitting of a space $Z$ is a pair of nonempty disjoint open subsets $W, W' \subset Z$ such that $W \cup W' = Z$.
Lemma. For a space $X$ the following are equivalent:
(a) $X$ is locally connected, i.e. for each $x \in X$ and each open neighborhood $U$ of $x$ there exists a connected open neighborhood $V$ of $x$ such that $V \subset U$.
(b) For each $x \in X$ and each open neighborhood $U$ of $x$ there exists a connected (not necessarily open) neighborhood $N$ of $x$ such that $N \subset U$.
(c) The components of each open subset of $X$ are open in $X$.
This is a standard characterization of locally connected spaces. See About locally path-connected spaces and Definition of locally pathwise connected. (For the sake of completeness we give a proof at the end of the answer, since the referenced proofs deals with locally path-connected spaces.)
We now prove the theorem.
$(1) \Rightarrow (2)$:
Let $U$ be an open neighborhood of the compact set $K$. Let $\mathcal C = \{C_\alpha\}_{\alpha \in A}$ denote the set of components of the open set $X \setminus K$. Since $X$ is locally connected, the $C_\alpha$ are open sets.
Case 1. $X$ is connected.
Since $X$ is locally compact Hausdorff, there exists an open neighborhood $V$ of $K$ such that $\overline{V}$ is a compact subset of $U$. In the sequel we only consider the case that $V \ne \emptyset$. (If $V =\emptyset$, then $K = \emptyset$ and $\mathcal C = \{ X \}$ so that the assertion is trivial.)
We claim that $C_\alpha \cap V \ne \emptyset$ for all $\alpha \in A$. To see this, assume that $C_{\alpha_0} \cap V = \emptyset$ for some $\alpha_0$. Then $(C_{\alpha_0}, V \cup \bigcup_{\alpha \ne \alpha_0} C_\alpha)$ forms a splitting of $X$ which is impossible.
Let $A'$ be the set of all $\alpha' \in A$ such that $C_{\alpha'}$ is not contained in $U$. We shall show that $A'$ is finite.
$B = \text{bd} V$ is compact. For $\alpha' \in A'$ we have $C_{\alpha'} \not\subset \overline{V}$, i.e. $C_{\alpha'} \setminus \overline{V} \ne \emptyset$. We also know that $C_{\alpha'} \cap V \ne \emptyset$. If $C_{\alpha'} \cap B = \emptyset$, we get a splitting $(C_{\alpha'} \setminus \overline{V}, C_{\alpha'} \cap V)$ of $C_{\alpha'}$ which is impossible. Hence $C_{\alpha'} \cap B \ne \emptyset$ for all $\alpha' \in A'$.
Now let $A''$ denote the set of all $\alpha'' \in $ such that $C_{\alpha''} \cap B \ne \emptyset$. Then $A' \subset A''$. We show that $A''$ is finite which finishes the proof.
By construction $\mathcal C'' = \{C_{\alpha''}\}_{\alpha'' \in A''}$ is an open cover of $B \subset X \setminus K$. The $C_{\alpha''}$ are pairwise disjoint, hence no proper subset of $\mathcal C''$ covers $B$. Since $B$ is compact, $\mathcal C''$ has a finite subcover $\mathcal C^* \subset \mathcal C''$. This is possible only when $\mathcal C^* = \mathcal C''$.
Case 2. $X$ is arbitrary with finitely many components $X_1,\dots,X_n$.
The $X_i$ are open and closed subsets of $X$, hence locally compact Hausdorff, locally connected and connected. Case 1 applies to the subsets $K_i = K \cap X_i$ and $U_i = U \cap X_i$ of $X_i$. Thus, if $\mathcal C_i$ denotes the set of components of $X_i \setminus K_i$, then the subset $\mathcal C'_i$ of elements of $\mathcal C_i$ which are not contained in $U_i$ is finite. But the set of components of $X \setminus K$ is the union of the $\mathcal C_i$ and the subset $\mathcal C'$ of elements of $\mathcal C$ which are not contained in $U$ is the union of the $\mathcal C'_i$, i.e. is finite.
$(2) \Rightarrow (1)$:
Taking $K = U = \emptyset$, we see that $X$ has only finitely many components.
Let $x \in X$ and $U$ be an open neighborhood of $x$. Since $X$ is locally compact Hausdorff, there exists an open neighborhood $V$ of $x$ such that $\overline{V}$ is a compact subset of $U$. Next choose any open neighborhood $W$ of $x$ such that $\overline{W} \subset V$. Then $U' = X \setminus \overline{W}$ is an open neighborhood of the compact set $B = \text{bd} V$.
Let $\mathcal C$ denotes the set of components of $X \setminus B$. We know that only finitely many $C_1,\dots, C_n \in \mathcal C$ are not contained in $U'$. Therefore $W \subset \bigcup_{i=1}^n C_i$. One of these components, say $C_1$, must contain $x$. Hence $C_1 \cap V \ne \emptyset$ and we conclude that $C_1 \subset \overline{V}$ (otherwise we would get a splitting $(C_1 \cap V, C_1 \cap (X \setminus \overline{V}))$ of $C_1$). Thus $C_1 \subset U$. The $C_i$ are closed in $X \setminus B$, hence also $C' = \bigcup_{i=2}^n C_i$ is closed in $X \setminus B$. Thus $C' \cap W$ is closed in $W \subset X \setminus B$. Hence $C_1 \cap W = W \setminus (C' \cap W)$ is open in $W$ and therefore also open in $X$. This shows that $C_1$ is a connected neighborhood of $x$ which is contained in $U$.
Proof of the Lemma:
(a) $\Rightarrow$ (b) : Obvious.
(b) $\Rightarrow$ (c) : Let $U \subset X$ be open and $C$ be a component of $X$. Consider $x \in C$. There exist an open neighborhood $V$ of $x$ and a connected $N \subset X$ such that $V \subset N \subset U$. Since $N \cap C \ne \emptyset$, we see that $N \cup C$ is a connected subset of $U$ which contains $C$. By definition of $C$ we see that $N \cup C = C$, i.e. $N \subset C$. We conclude $V \subset C$.
(c) $\Rightarrow$ (a) : Let $U$ be a neighborhood of $x \in X$ and $C$ be the component of $U$ which contains $x$. This is an open neighborhood of $x$ contained in $U$.