Is there any function $f:\mathbb R \rightarrow \mathbb R$ such that it is only continuous at rational numbers? Is there any function $$f:\mathbb R \rightarrow \mathbb R$$ such that it is only continuous at rational numbers?
 A: No.  The reason is that the points of continuity of a function form a $G_\delta$
set, i.e. the intersection of a countable collection of open sets.  This
can be seen by writing it as the intersection of $U_m$ for all positive 
integers $m$, where x is in $U_m$ if there is some $\epsilon > 0$ such that
for all $y$ and $z$ in the interval $(x-\epsilon,x+\epsilon)$, $|f(y)-f(z)| < 1/m$.  $U_m$ is an open set.
As a consequence of the Baire Category Theorem, the rational numbers are 
not a $G_\delta$. 
A: You ask if there is a function that is only continuous at rational numbers. The function
$$
f(x) = \begin{cases}x & \text{if } x \text{ is rational} \\
-x & \text{if } x \text{ is irrational}
 \end{cases}
$$
is only continuous at $0$. So it is only continuous at rational numbers.
Now, if you meant to ask whether there is a function with domain the real numbers that is continuous at exactly all the rational numbers and discontinuous anywhere else, then no such  function exists. The other answers give you reasons for this.
A: No, there is no function $f:\mathbb{R} \rightarrow \mathbb{R}$ that is only continuous at the rational numbers. The set of discontinuities must be an $F_{\sigma}$ set, which the irrationals are not. 
If you change the question and ask about a function that is only continuous at the irrational numbers, then the answer is yes. Consider Thomae's function $f(x)=\begin{cases}
  \frac{1}{q} &\text{if }x\text{ is rational, }x=\tfrac{p}{q}\text{ in lowest terms and } q > 0\\
  0           &\text{if }x\text{ is irrational.}
\end{cases}$
