I think I have a proof for the statement, but I can't think of a counter-example when $f: \mathbb{R} \to \mathbb{R}$ is not continous. Here's the problem:
Let $f: \mathbb{R} \to \mathbb{R}$ be a continuous periodic function with two incommensurate periods $T_1$ and $T_2$; that is $\displaystyle \frac{T_1}{T_2}$ is irrational. Prove that $f$ is a constant function. Give an example of a nonconstant periodic function with two incommensurate periods.
Consider the set $G= \{n_1T_1+n_2T_2 : n_1,n_2 \in \mathbb{Z} \}$.
It's straight forward to verify that this set forms a subgroup of $\mathbb{R}$ under addition.
Since $\displaystyle \frac{T_1}{T_2}$ is irrational, $G$ will not be cyclic, because if it's cyclic, then there exists an element $m_1T_1+m_2T_2 \in G$ such that for any $n_1T_1+n_2T_2 \in G$ there exists a $p \in \mathbb{Z}$ such that:
$$n_1T_1 + n_2T_2 = p (m_1T_1+m_2T_2)$$
Rearranging the terms we obtain:
$$\frac{T_1}{T_2} = \frac{n_2-pm_2}{pm_1 -n_1} \in \mathbb{Q}$$ Which is contradiction. Therefore $G$ is not cyclic. Since $G$ is a subgroup of $\mathbb{R}$ which is not cylic, we conclude that $G$ is dense in $\mathbb{R}$.
Assume that $f(0)=C$. I'm going to show that $f(x)=C$.
Since $G$ is dense in $\mathbb{R}$, every point $x \in \mathbb{R}$ can be approached by elements of $G$ of the form $n_1T_1+n_2T_2$. In particular, for any $\delta>0$ there exists $c_1,c_2 \in \mathbb{Z}$ such that:
$$ |x - (c_1T_1+c_2T2)| < \delta$$
Since $f$ is assumed to be continuous, this means that for any $\epsilon>0$ we have:
$$|f(x) - f(c_1T_1+c_2T_2)|< \epsilon$$
but $f(c_1T_1+c_2T_2)=f(c_2T_2)=f(0)=C$.
Therefore, for any $x \in \mathbb{R}$ we have shown that $\forall \epsilon>0: |f(x)-C|< \epsilon$ which implies $f(x)=C$.
I can't think of a counter-example for when $f$ is not continuous. Can someone suggest a counter-example?