If $X$ is a locally compact Hausdorff space, one says that a function $f\colon X \to \mathbb{R}$ "vanishes at infinity" if for every $\varepsilon > 0$ there is a compact $K_{\varepsilon} \subset X$ such that $\lvert f(x)\rvert < \varepsilon$ for all $x\in X\setminus K_{\varepsilon}$.
If $X^{\ast} = X \cup \{\infty\}$ is the one-point compactification of $X$ (which is in fact not a compactification if $X$ is already compact, since then $X$ is closed in $X^{\ast}$ and thus not dense), then $f$ vanishes at infinity if and only if the function
$$\hat{f} \colon x \mapsto \begin{cases} f(x) &, x \in X \\ 0 &, x = \infty\end{cases}$$
is continuous at $\infty$.
So while the concept can be defined and understood without mentioning the one-point compactification, it is more transparent when viewed in the context of the one-point compactification.
Does every continuous function have a continuous extension to the compact topology given by the one point compactification?
No, we have a continuous extension to $X^{\ast}$ only if the function vanishes at infinity or differs by a constant from a function vanishing at infinity. Viewing $X$ as a subspace of $X^{\ast}$, if $X$ is not itself compact that is the case if and only if $\lim\limits_{x\to\infty} f(x)$ exists. If $X$ is already compact, $\infty$ is an isolated point in $X^{\ast}$, so every continuous function on $X$ can be arbitrarily extended to $X^{\ast}$ to yield a continuous function.
That answers the last question, the continuous extension, if it exists, is unique if and only if $X$ is not compact.
A side note: A subspace $X$ of a locally compact Hausdorff space $Y$ that is itself locally compact in the subspace topology is the intersection of a closed subset and an open subset of $Y$, hence it is a Borel set. So the premise that $S$ be a Borel subset of $\mathbb{R}^d$ is redundant, it is implied by the premise that $S$ be locally compact.
The commutativity $f = \phi \circ g$ forces the definition of $g$: if $x \in X$, then $g(x) \in g[X]$ and $\phi$ must map $g(x)$ to $f(x)$, which is essentially $x$ but seen in its one-point compactification $X^\ast$. So $\phi(x)$ is determined on the dense set $g[X]$ of $Y$ so is unique as $X^\ast$ is Hausdorff.
(Theorem: if $f,g: X \to Y$ are continuous, $D$ is dense in $X$, and $Y$ Hausdorff, then $f\restriction_D = g\restriction_D$ implies $f=g$ on $X$.) And defining $\phi(x)$ to be $\infty$ (what you call $\ast$) on $Y\setminus g[X]$ does not affect the commutativity of the diagram and is a choice that makes $\phi$ continuous, as we'll see. But first:
Theorem: if $X$ is locally compact Hausdorff and $Y \subseteq X$ is locally compact in the subspace topology, then $Y=C \cap O$ where $O \subseteq X$ is open and $C\subseteq X$ is closed.
From the theorem we have that $g[X]$ is open in $Y$ when $g:X \to Y$ is a Hausdorff compactification and $X$ is locally compact Hausdorff.
Now to the continuity of $\phi$ as we defined above: if $U \subseteq X^\ast$ is open, it's either a subset of $X$ (I'll forget about $f$, $X^\ast=X \cup \{\infty\}$ and the embedding is standard: $f(x)=x$) and then $\phi^{-1}[U]$ is $g[U]$, which is open in $Y$ (as $g[U]$ is open in $g[X]$ and $g[X]$ is open in $Y$), or
$U=X^\ast \setminus K$ where $K \subseteq X$ is compact. Then $\phi^{-1}[U]= Y\setminus g[K]$ which is open in $Y$ too ($g[K]$ is compact, hence closed, as $Y$ is Hausdorff). So $\phi$ is continuous and we already saw it commutes in the right way and is unique by the denseness argument.
Best Answer
Let $g:A\to\mathbb{R}$ and $*$ be the unique point added to $A$, i.e. $B=A\cup\{*\}$.
"$\Rightarrow$" Let $g':B\to\mathbb{R}$ be the extension of $g$. Put $c:=g'(*)$. We will show that $g-c$ vanishes.
So pick $\epsilon > 0$ and define
$$U=\{b\in B\ |\ |g'(b)-c| < \epsilon\}$$
So $U=f^{-1}(-\infty, \epsilon)$ for $f(b)=|g'(b)-c|$. Since $g'$ is continous then so is $f$ and thus $U$ is open in $B$.
Therefore $C:=B\backslash U$ is compact (being a closed subset of a compact space). Note that $*\not\in C$ since $*\in U$ because $|g'(*)-c|=0<\epsilon$. Thus $C=A\cap C$ and therefore $A\cap C$ is a compact subset of $A$ that satisfies desired properties. This completes the proof. $\Box$
"$\Leftarrow$" Let $c\in\mathbb{R}$ be such that $g-c$ vanishes. Define
$$g':B\to\mathbb{R}$$ $$g'(x)=\begin{cases} g(x) & \mbox{ if } x\in A \\ c & \mbox{ if } x= * \end{cases}$$
Obviously $g'$ extends $g$. All that is left is to prove that $g'$ is continous. Can you complete the proof?
So it is enough to prove that if $c\in(a,b)$ for some $a,b\in\mathbb{R}$ then $g'^{-1}(a,b)$ is open in $B$. Let $x\in g'^{-1}(a,b)$. If $x\neq *$ then there exists an open neighbourhood $U$ of $x$ in $A$ (and thus in $B$) such that $g'(U)=g(U)\subseteq (a,b)$ (by continuity of $g$). Therefore the only thing that we actually have to prove is the existence of a neighbourhood $U$ of $*$ such that $g'(U)\subseteq (a,b)$.
Take $\epsilon := \min\big(|b-c|, |a-c|\big) > 0$. Since $g-c$ vanishes then there exists a compact subset $C\subset A$ such that
$$g(A\backslash C)\subseteq (c-\epsilon, c+\epsilon)\subseteq (a,b)$$
By the definition of the one point compactification $U:=A\backslash C\cup\{*\}$ is open in $B$ and since $g'(*)=c$ then $g'(U)\subseteq (a,b)$ which completest the proof. $\Box$