A small compass needle of magnetic moment M

A small compass needle of magnetic moment M and moment of inertia I is free to oscillate in a magnetic field B. It is slightly disturbed from its equilibrium position and then released. Show that it executes simple harmonic motion. Hence, write the expression for its time period.

As the needle is displaced from the equilibrium position, the torque will try to bring it back in equilibrium position. Hence, acceleration will be related with negative of angular displacement.
When compass needle of magnetic moment M and moment of inertia I is slightly disturbed by an angle θ from the mean position of equilibrium, then restoring torque begins to act on the needle which in turn, try to bring the needle back to its mean position.