I know that if $f(t)= \cos (at)e_1+ \sin(at)e_2$, then $\ddot f(t)=-a^2 f(t)= \pm N(f(t))\perp T_{f(t)}S$, where $N(p)= \frac{\nabla f(p)}{\|\nabla f(p)\|}$ is the unit normal vector, $S= g^{-1}(1), g(x_1,x_2,...,x_{n+1})= \sum_{i=1}^{n+1} x_i^2$ and $T_{f(t)}S=$ the tangent space to $S$ at $f(t)$. Hence, it follows that $f$ is a geodesic on $S$.
I'm not sure how to show the converse: Given a geodesic $f$ on $S$, it is of the form $f(t)= \cos (at)e_1+ \sin(at)e_2; e_1,e_2$ are orthogonal vectors in $\mathbb R^{n+1}$.
Suppose that $f(t)$ is a geodesic on the sphere, then $\ddot f(t)= c f(t)$, because $N(f(t))= f(t)$. With this, one gets $f_i(t)= d_i e^{\sqrt c t}+d_i' e^{\sqrt{-c} t}$ so that $f(t)= (f_i(t))_{i=1,2,..., n+1}$. But I don't understand how to show from here that $f(t)$ is of the aforementioned form.