I claim that it is always possible (as long as one does not require the derivatives of $\tilde{f}_{X\setminus K}$ to be bounded). This is actually an easy consequence of the approximation theorem of manifolds.
To state the approximation theorem of manifolds, suppose that
$0\leq s<\infty$, and $M,N$ are manifolds. Let $C^{s}(M,N)$ be the collection of $C^{s}$ mappings from $M$ to $N$. Then we shall let $C^{s}_{S}(M,N)$ denote the topological space with underlying set $C^{s}(M,N)$ and where the basic open sets are the sets of the following form.
Suppose that $\iota_{n}:U_{n}\rightarrow M$ is a chart for each $n\geq 0$. Suppose that $(\iota_{n}[U_{n}])_{n\geq 0}$ is locally finite. Suppose furthermore that $C_{n}$ is a compact subset of $\iota_{n}[U_{n}]$ and $\epsilon_{n}>0$ for all natural numbers $n$. Let $f\in C^{s}(M,N)$. Suppose now that $j_{n}:V_{n}\rightarrow N$ is a chart for each $n\geq 0$ and that $f[C_{n}]\subseteq j_{n}[V_{n}]$. Let $O$ be the collection of all functions $g\in C^{s}(M,N)$ such that
$g[C_{n}]\subseteq j_{n}[V_{n}]$ and where if $\alpha$ is a multi-index with $|\alpha|\leq s$, then
$$|D^{\alpha}(j_{n}^{-1}f\iota_{n})(x)-D^{\alpha}(j_{n}^{-1}f\iota_{n})(x)|<\epsilon_{i}$$ for each $x\in \iota_{n}^{-1}[C_{n}]$. Then $O$ is a basic open set, and all basic open sets are of this form.
Theorem (approximation theorem): Let $M,N$ be $C^{q}$ manifolds where $1\leq q\leq\infty$. Suppose that $0\leq p<q$. Then the set $C^{q}(M,N)$ is dense in the space $C_{S}^{p}(M,N)$.
A good textbook reference for the above result is the text Differential Topology by Morris Hirsch.
Suppose now that $X$ is a compact space, $K$ is a compact subset of $X$, and $X\setminus K$ is a $C^{\infty}$-manifold.
Then there exists a continuous function $h:X\rightarrow[0,1]$ where
$K=h^{-1}[\{0\}]$.
Let $O$ be the collection of all continuous functions $g:X\setminus K\rightarrow\mathbb{R}$ with $|(g-f)(x)|<h(x)$ for all $x\in X$. Then $O$ is open in $C_{S}^{0}(X\setminus K,\mathbb{R})$, so by the approximation theorem, there exists a $C^{\infty}$-mapping
$g:X\setminus K\rightarrow\mathbb{R}$ with $g\in O$, and in this case, $|(g-f)(x)|<h(x)$ for each $x\in X$.
Observe that if $k\in\partial K$, then $\lim_{x\in X\setminus K,x\rightarrow k}(g-f)(x)=0$, so $\lim_{x\in X\setminus K,x\rightarrow k}f(x)=\lim_{x\in X\setminus K,x\rightarrow k}g(x)$. Therefore, if we set $\overline{g}=g\cup f|_{K}$, then $\overline{g}$ is a continuous function that extends $g$.
Pierre PC observed that we do not need the full strength of the approximation theorem and that the weaker result that is easier to state and prove will suffice:
Proposition: Whenever $M$ is a $C^{k}-$manifold for $1\leq k\leq\infty$, $f:M\rightarrow\mathbb{R}$ is continuous, and $h:M\rightarrow(0,\infty)$ is a continuous function, there exists some $C^{k}$-function $g:M\rightarrow\mathbb{R}$ with $|f-g|<h$.
To prove the above proposition, first observe that if $U\subseteq\mathbb{R}^{n}$, $U$ is open, and $f:U\rightarrow\mathbb{R}$ is continuous, then for all $\delta>0$, there is a $C^{\infty}$-function $g_{\delta}:\mathbb{R}^{n}\rightarrow[0,\infty]$ where $g_{\delta}(x)=0$ whenever $\|x\|>\delta$ and where $\int_{\mathbb{R}^{n}}g_{\delta}(\mathbf{x})d\mathbf{x}=1$. In this case, each $f*g_{\delta}$ is $C^{\infty}$ on $\{\mathbf{x}\mid B_{\delta}(\mathbf{x})\subseteq U\}$ and $f*g_{\delta}\rightarrow f$ uniformly on compact sets. One can extend this approximation result to obtain a proof of our proposition using a $C^{k}$-partition of unity.
$
ending your\newcommand
environment on the same line as the beginning of the text, or else your post will start with blank space. I have edited accordingly. $\endgroup$