As Jason and Gerald predicted, the answer is yes for Polish $X, Y$. (Indeed, it is sufficient for $X$ to be merely separable and metrizable and for $Y$ to be merely complete and metrizable.)
As Nate observed, we may assume that $D$ is $G_\delta$. Here is the key fact:
Lemma. If $D \subseteq X$ is a nonempty $G_\delta$-set then there is a Borel map $h:X \to D$ such that $\lim_{x\to x_0} h(x) = x_0$ for every $x_0 \in D$.
Suppose $D = \bigcap_{n\lt\omega} U_n$, where $(U_n)_{n\lt\omega}$ is a descending sequence of open sets such that $U_n \subseteq \bigcup_{x_0 \in D} B(x_0,1/(n+1))$. Any functionBorel retraction $h:X \to D$ with the property that if $x \in U_n \setminus U_{n+1}$ then $d(h(x),x) \lt 1/(n+1)$ will be as required. By definition, it is always possible to find a suitable $h(x) \in D$ for each $x \in U_0$$x \in U_0 \setminus D$. To ensure that $h$ is Borel, fix an enumeration $(d_i)_{i \lt \omega}$ of a countable dense subset of $D$ and, if $x \in U_0 \setminus D$, define $h(x)$ to be the first element in this list that matches all the necessary requirements. (We must have $h(x) = x$ for $x \in D$, and it doesn't matter how $h(x)$ is defined when $x \notin U_0$ so long as the end result is Borel.)
Now, if $f:X \to Y$ is Borel and continuous on $D$, then $g = f\circ h$ is a Borel function that agrees with $f$ on $D$ and $$\lim_{x \to x_0} g(x) = f(\lim_{x \to x_0} h(x)) = f(x_0) = g(x_0)$$ for all $x_0 \in D$.