Let us proceed by the $\epsilon$-$\delta$ definition of continuity.
It is to be shown that $$\forall \epsilon >0 \exists \delta >0: |x|<\delta \implies |f(x)-f(0)|<\epsilon$$
Since $f(0) = 0$, this comes down to $|f(x)|<\epsilon$. Now take $\delta = \epsilon$.
Suppose that $x \in \Bbb R$ has $|x| < \delta$.
Then if $x \in \Bbb Q, |f(x)| = 0 < \epsilon$. If $x \
otin \Bbb Q, |f(x)| = |x| < \delta = \epsilon$.
Thence $f$ is continuous at $0$. At other points a similar case distinction can be used to show that $f$ is discontinuous.