For convenience, we rewrite the equation
\begin{align}
f'' + \omega^2 \sin f = 0
\end{align}
in the form of a system:
$$\tag{1}
\left\{\begin{array}{lll}
\dot x&=&y\\
\dot y&=&-\omega^2 \sin x.
\end{array}\right.
$$
The system (1) has the first integral/conserved quantity
$$
V(x,y)= \omega^2(1-\cos x) +\frac{y^2}2.
$$
It means that it remains constant along the trajectories of (1). Indeed, let $(x(t),y(t))$ be the solution to (1). Then the derivative along the trajectories
$$
\dot V= \frac{d}{dt}V(x(t),y(t))= \frac{\partial V}{\partial x}\frac{dx}{dt}+
\frac{\partial V}{\partial y}\frac{dy}{dt}= \omega^2\sin x \cdot y + y(-\omega^2 \sin x)\equiv 0.
$$
This implies that any solution $(x(t),y(t))$ lies on the level curve of $V$. By drawing these level curves $V(x,y)=C$, one can see that not all of them are closed:
One can study the form of the level curves
$$
\omega^2(1-\cos x) +\frac{y^2}2=C
$$
using the fact that they are composed of two graphs of functions:
$$\tag{2}
y=\pm \sqrt{ 2C-2\omega^2(1-\cos x) }.
$$
If $C>2\omega^2$, then $2C-2\omega^2(1-\cos x)>4\omega^2-2\omega^2+2\omega^2\cos x=
2\omega^2(1+\cos x)\ge0$ and the level curve splits into two separate function graphs, one in the upper, the other in the lower half-plane. Thus, the level curve does not contain a closed curve and therefore the corresponding solution is not periodic.
If $C<2\omega^2$, then two graphs, symmetrical about the $x$ axis, touch at the points of this axis and form a closed curve.
To prove that the solutions corresponding to the values $C<2\omega^2$ are periodic, one can use the uniqueness of the solution to the initial value problem. If the solution, having passed along a closed trajectory, returned to the starting point, then the next turn will be identical to the one passed due to the coincidence of the initial conditions. On the other hand, the state cannot stop halfway without going through a full turn along a closed curve, since the velocity of the movement can be bounded from below for any curve, except for the equilibrium points and heteroclinic orbits (see below). As a result, the state travels a finite distance on the phase plane in a finite time.
$C=2\omega^2$ (drawn in red) is a special case. It corresponds to the set of heteroclinic orbits.
Update By the way, the representation (2) allows to calculate the period of oscillation. Let us choose some particular constant $C<2\omega^2$. The curve (2) near the origin intersects the x-axis at the points
$$
x=\pm\arccos\left(1-\frac{c}{\omega^2} \right).
$$
Denote $r=\arccos\left(1-\frac{c}{\omega^2} \right)$.
Since $x$ is $f$ and $y$ is $f'$, we have (for definiteness, we choose the upper half of the curve)
$$
\frac{df}{dt}= \sqrt{ 2C-2\omega^2(1-\cos f) }
$$
$$
\frac{df}{\sqrt{ 2C-2\omega^2(1-\cos f) }}=dt.
$$
Integrating over the upper half of the closed curve, we obtain
$$
\int_{-r}^{r}\frac{df}{\sqrt{ 2C-2\omega^2(1-\cos f) }}=\int_{0}^{T/2}dt
$$
and
$$
T/2=\int_{-r}^{r}\frac{df}{\sqrt{ 2C-2\omega^2(1-\cos f) }}.
$$