Let us show how to find such a retraction for $n=2$ (I do not know if this method generalizes to higher dimensions).
Given a compact set $C\subset\mathbb R^2$ and an open neighborhood $U\subseteq\mathbb R^2$ of $C$, choose a triangulation on $\mathbb R^2$ so fine that no triangle of the triangulation meets $C$ and $\mathbb R^2\setminus U$ simultaneously.
Replacing the triangulation by a finer triangulation, we can assume that for each triangle $T$ with $T\not\subseteq C$, one vertex of $T$ does not belong to $C$.
How to find such a triangulations? Assuming that $T\not\subseteq C$, we can find an interior point $v$ of $T$ that does not belong to $C$ and replace the triangle $T$ by 3 subtriangles having $v$ as a vertex.
Also we can assume that either $T\subseteq\mathbb R^2\setminus C$ or $T$ has a vertex in $C$. Assuming that $T$ has no vertices in $C$ but $T\cap C\ne\emptyset$, we can choose a point $c\in T\cap C$ and replace the triange $T$ by two or three triangles having $c$ as a vartex.
Therefore, we lose no generality assuming that each triangle $T$ of the triangulation has one of the following properties:
1) $T\subseteq C$;
2) $T\cap C=\emptyset$;
3) $T$ has one vertex in $C$ and one vertex outside of $C$;
4) If two vertices $u,v$ of $T$ do not belong to $C$, then the side $[u,v]$ does not intersect $C$.
A triangle $T$ will be called difficult if it has one vertex say $u$ outside $C$, two vertices $v,w$ in $C$ and the side $[v,w]$ is not a subset of $C$.
In this case choose any point $c[v,w]\in [v,w]\setminus C$. The points $c[v,w]$ can be chosen so that for two difficult triangle sharing the common side $[v,w]$ the point $c[v,w]$ is the same.
Now for every triangle $T$ of the triangulation we define a function $r_T\setminus C:T\to T\setminus C$ such that $r_T\circ r_T=r_T$ as follows. In case (1), let $r_T$ be the empty map and in case (2) $r_T$ be the idenity map of $T$.
In the remaining cases, the triangle $T$ has one vertex in $C$ and one vertex outside of $C$. If the triangle $T$ is not difficult, then it has two vertices $u,v$ such that the side $[u,v]$ either is contained in $C$ or is disjoint with $C$. If $[u,v]$ is contained in $C$, then let $r_T:T\setminus C\to\{w\}$ be the constant map into the unique vertex $w\notin C$ of $T$.
If $[u,v]\cap C=\emptyset$, then the third vertex $w$ of $T$ belongs to $C$ and we can apply the Urysohn lemma to find a function $r_T:T\setminus C\to[u,v]$ such that $r_T[[w,u]\setminus C]=\{u\}$, $r_T[[w,v]\setminus C]=\{v\}$, and $r_T(x)=x$ for every $x\in [u,v]$.
It remains to consider the case of a difficult triangle $T$. Such a triangle has one vertex $u$ outside of $C$, two vertices $v,w$ in $C$ and the point $c[v,w]\in [v,w]\setminus C$. Two cases are possible.
1) There exists a path $\gamma:[0,1]\to T\setminus C$ such that $\gamma(0)=u$ and $\gamma(1)=c[v,w]$. We can assume that $\gamma$ is injective and hence its image $A_T=\gamma[0,1]$ is an arc with endpoints $u$ and $c[v,w]$. Using the Urysohn Lemma, we can find a continuous function $r_T:T\setminus C\to A_T$ such that $r_T[([u,v]\cup[u,w])\setminus C]\subseteq \{u\}$, $r_T[[v,w]\setminus C]\subseteq\{c[v,w]\}$ and $r_T(a)=a$ for every $a\in A_T$.
2) No such a path $\gamma$ exists. Then the points $u$ and $c[v,w]$ belong to distinct connected components of $T\setminus C$. In this case we can choose a continuous map $r_T:T\setminus C\to\{u,c[v,w]\}$ such that $r_T[([u,v]\cup[u,w])\setminus C]\subseteq\{u\}$ and $r_T[[v,w]\setminus C]\subset\{c[v,w]\}$.
The definitions of the maps $r_T$ ensure that they agree on the intersections of their domains. Consequently, the union $r=\bigcup_T r_T$ of these maps is a continuous function $r:\mathbb R^2\setminus C\to\mathbb R^2\setminus C$ such that $r\circ r=r$. So, $r$ is a retraction onto the closed subset $F$ which can be written as the union of the triangles of the triangulation that do not intersect $C$, some vertices of the triangles that intersect $C$ and the arcs $A_T$ of difficult triangles (of the first type).
The choice of the triangulation $T$ (as sufficiently fine) implies that $V=\mathbb R^2\setminus F$ is a neighborhood of $C$ with $\bar V\subset U$. Then $r{\restriction}U\setminus C$ is the required retraction of $U\setminus C$ onto $U\setminus V$.