Give an example of a complete metric space $(X,d)$ and its compact subset $K$, that the set $C= \{x \in X: \text{dist} (x,K) ≤\frac 12 \}$ is not compact.
From Heine-Borel theorem: completeness + totally boundation = compactness. The set $C$ is closed so also complete. Therefore, lest C be compact, then C cannot be tatally bounded. However I have no idea which $(X,d)$ and $C$ to choose to fulfill this.
Let me write some comments in order to address the difficulty of finding a "nice" example and, in contrast to this, give you a really neat one.
Consider the function $f:X\to \mathbb{R}$ given by $f(x)=\text{dist}(x,K)$. It is easy to see that $f$ is a Lipschitz continuous map and that our set $C$ is simply $f^{-1}\left[(-\infty, \frac{1}{2}]\right]$. It is immediate from this, as you pointed out, that $C$ is a closed subset of $X$. Another easy but maybe not immediate fact is that $C$ is bounded.
To see this, let's use that $K$ is a bounded subset of $X$ to fix $z\in X$ and $r>0$ in such a way that $K\subseteq B_{X}(z,r)$. Now, I would like to prove that $C\subseteq B_{X}(z,r+1)$. For any $x\in C$, there exists a $y\in K$ such that $d(x,y)\leq 1$ (if this wasn't the case, then we can prove that $1\leq f(x)$, contradicting that $x\in C$). Then, the triangle inequality gives us
$$d(x,z) \leq d(x,y) + d(y,z) < 1+r.$$
This proves that $C$ is a bounded subset of $X$.
Now, if $X$ was a finite-dimensional Banach space then, since the Heine-Borel Theorem holds for every finite-dimensional normed vector space, $C$ would automatically be a compact subset of $X$, and we don't want this. So, if we try to find an example of a set $C$ which is not compact in a Banach space $X$, we need $X$ to be infinite-dimensional. This rules out our favorite spaces, such as $\mathbb{R}^{n}$ and $\mathbb{C}^{n}$.
Consider now the space of all bounded sequences of real numbers $\ell_\infty$. It is well known that $\ell_\infty$ is an infinite-dimensional Banach space. Let $\overline{0}$ denote the element of $\ell_\infty$ with zeroes in every entry, and put $K=\{\overline{0}\}$. Observe that, since $K$ is finite, $K$ is a compact subset of $\ell_\infty$. Lastly, notice that $$C=\overline{B}_{\ell_\infty}(\overline{0},\frac{1}{2})=\left\{x\in \ell_\infty : d_{\ell_\infty}(x,\overline{0})\leq \frac{1}{2}\right\}.$$
From this we deduce that $C$ is homeomorphic to the closed unit ball in $\ell_\infty$. Since $\ell_\infty$ has infinite dimension, the closed unit ball is not compact (this is a nice corollary of Riesz's Lemma; check out the section of "Some consequences" in https://en.wikipedia.org/wiki/Riesz%27s_lemma) and so, $C$ is not compact.
Hope this helps.