Since $f$ is continuous, your assumptions imply that $f=g$ on the entire $X$. Hence, $g$ is continuous.
Edit: As John correctly noted, the above sentence is insufficient since $f$ is only defined on $E$. Here is the detailed proof of continuity of $g$ on $X$, not merely on $D$.
First, it is clear from continuity of $f: D\to Y$ and the hypothesis, that $f=g$ on $D$. The statement now follows from the following:
Lemma. Suppose that $Y$ is regular. Let $E\subset X$ be a dense subset of a topological space $X$ and let $f: X\to Y$ be a map such that for every $x\in X$ and every net $(e_\gamma)$ in $E$ converging to $x$, we have
$$
f(x)\in \lim_\gamma f(e_\gamma).
$$
($Y$ need not be Hausdorff, so $\lim_\gamma y_\gamma$ is the set of all limits of the net $(y_\gamma)$ in $Y$.)
Then $f$ is continuous on $X$.
Proof. Let $x\in X$, $(x_\alpha)$ be a net in $X$ converging to $x$. Suppose that the net $y_\alpha=f(x_\alpha)$ does not converge to $y=f(x)$. Then, without loss of generality, after passing to a subnet, we can assume that the closure $A$ of the (image of the) net $(y_\alpha)$ in $Y$ does not contain $y$. By regularity of $Y$, there exists a pair of disjoint open sets $U$ and $V$ with $y\in U$, $A\subset V$.
Since $E$ is dense in $X$, for each $x_\alpha\in X$, there exists a net $(e_{\alpha,\beta})$ in $E$ converging to $x_{\alpha}$. By assumption,
$$
f(x_\alpha)= \lim_\beta f(e_{\alpha,\beta}).
$$
Now, use the "standard" diagonal net argument (which you probably have seen many times in the case of sequences), there exists a net $(e_\gamma)$ in $E$ which converges to $x$ and whose elements are all of the form
$e_{\alpha,\beta}$. Hence, by the assumption, the net $f(e_\gamma)$ converges to $y=f(x)$.
On the other hand, since
$$
\lim_\beta f(e_{\alpha,\beta})=y_\alpha \in V,
$$
we may choose the net $(e_\gamma)$ so that $f(e_\gamma)\in V$ for all $\gamma$ in the directed set. Contradiction with the fact that $f(e_\gamma)$ converges to $y\in U$ and $U$ is disjoint from $V$. qed