Clearly there are geodesics which are not periodic. Take the maximal torus of say $SO(4)$, and let 
$$ 
X = \begin{pmatrix} J & 0 \\
 0 & \alpha J \end{pmatrix} 
$$

 be in block diagonal form, where $J = \begin{pmatrix} 0 & 1  \\ -1 & 0 \end{pmatrix}$, with $\alpha$ irrational. Then the geodesic generated by $X$ will be dense in the set of 2x2 block diagonal elements of $SO(4)$, but is not the whole set, hence can't be closed.