As noted in the comments, this is a slightly more general version of a problem in Rudin. I assume for simplicity that the dense set is $\mathbb{Q}$.
Solution: Fix $x_0\in\mathbb{R}$, and fix a sequence $\{x_n\}$ converging to $x_0$. By the sequential characterization of continuity, it suffices to show that $f(x_n)\rightarrow f(x_0)$. Suppose not. Then an infinite number of the $f(x_n)$ are not equal to $f(x_0)$, and without loss of generality, we can assume there are infinitely many $n$ so that $f(x_n)>f(x_0)$. Passing to a subsequence, we can assume this is true for all $n$.
Because the sequence $\{f(x_n\}$ does not converge to $f(x_0)$, there exists $r\in\mathbb{Q}$ with $f(x_n)>r>f(x_0)$ for all $n$. By the intermediate value property, for every $n$, there exists $t_n$ with $f(t_n)=r$ for some $t_n$ between $x_n$ and $x_0$. By the squeeze principle, $t_n\rightarrow x_0$. But the set of all $t$ with $f(t)=r$ is closed, so because $x_0$ is a limit point, $f(x_0)=r$, a contradiction.
Source: W. Rudin, Principles of Mathematical Analysis, Chapter 4, exercise 19.