It's harder to prove the converse. Suppose that f(x) is periodic. Then will also be periodic, with the same period. But when x=0, f(0)=f''(0)=0. If there is another point, say x=c, at which f(c)=f''(c)=0, and a≠±1, then you should be able to show that sin(c) = sin(ac) = 0. With c≠0, this is only possible if a is rational. But if there is no such point c then f cannot be periodic.
But if then x must be a multiple of π. Therefore both c and ac are multiples of π, say c=nπ and ac=mπ. Then a=m/n, which is rational.