Let $\epsilon > 0$. Let $\delta = \epsilon$. Note that $f(0) = 0$.
Let $x \in \mathbb R$ be such that $|x - 0| < \delta$, i.e. $|x| < \delta$. Then, $|x| < \epsilon$.
If $x \in \mathbb Q$, then $|f(x) - f(0)| = |f(x)| = |x| < \epsilon$.
If $x \notin \mathbb Q$, then $|f(x) - f(0)| = |f(x)| = |0| = 0 < \epsilon$.
Therefore $f$ is continuous at $0$.
Let $a$ be irrational and suppose that $f$ is continuous at a.
Due to the denseness of $\mathbb Q$ in $\mathbb R$, there is a sequence $(x_n)_n$ of rationals converging to $a$.
Due to the continuity of $f$ at $a$, we have that $(f(x_n))_n$ converges to $f(a)$.
$a$ is irrational, so $f(a) = 0$. Then, $f(x_n) \rightarrow 0$.
For each $n \in \mathbb N$, $f(x_n) = x_n$ since all the terms of $(x_n)_n$ are rationals. Thus, $x_n \rightarrow 0$. The uniqueness of limits gives $a = 0$.
Now, let $a$ be rational and use the denseness of $\mathbb R - \mathbb Q$ to prove that $a = 0$.
This shows that $f$ can't be continuous at any point but $0$.