The second term is simply the time dependent external force. It can have any sign and also any functional shape as you like. The harmonic shape is particularly interesting since you can describe any external force by a Fourier series (periodic force) or a Fourier integral (non-periodic force).
The general solution for any external force is given with help of the retarded Green's function of the corresponding differential operator of the homogeneous equation, i.e., which obeys the equation of motion with a \delta force,
(\partial_t^2+\omega_0^2) G(t,t')=\delta(t-t'). \qquad (1)
If you can find the Green's function, for any external force, a solution reads
x(t)=\int_{-\infty}^{\infty} \mathrm{d} t' G(t,t') \frac{F(t')}{m}.
To find the Green's function, you make the ansatz
G(t,t')=\begin{cases} 0 & \text{for} \quad t<t', \\<br />
g(t,t') & \text{for} \quad t>t'.<br />
\end{cases}
The imposed condition for the Green's function to vanish for t<t' ensures that the external force only acts from the past and not the future on the position of the particle as it must be according to causality. That's what distinguishes the retarded propagator from any other solution of the Green's-function equation.
To solve it, you can simply use the fact that for t\neq t' the \delta distribution vanishes, and then the solution reads
g(t,t')=A \exp(\mathrm{i} \omega_0 t)+B \exp(-\mathrm{i} \omega_0 t). \qquad (2)
Now we need two initial conditions to determine the integration constants, A and B. The first is given by the continuity of G(t,t') at t=t', i.e., we must have
g(t'+0^+,t')=0. \qquad (3)
The second condition we find by integrating (1) over an infinitesimal interval t \in (t'-0^+,t'+0^+), leading to the condition on the jump of the first derivative:
\partial_t G(t'+0^+,t')-\partial_t G(t'-0^+,t')=\partial_t G(t'+0^+,t')=\partial_t g(t'+0+,t') \stackrel{!}{=} 1. \qquad (4)
Plugging (3) and (4) in (2) leads to
A+B=0, \quad A-B=\frac{1}{\mathrm{i} \omega_0} \; \Rightarrow A=-B=\frac{1}{2 \mathrm{i} \omega_0}.
This finally gives
G(t,t')=\Theta(t-t') \frac{\sin(\omega_0 t)}{\omega_0}.