It really depends on the problem and what you want to capture. Usually, in classes, it may be beneficial for the students at an initial stage to disregard gravity alltogether in order to simplify the equations of motion. Below are a few scenarios, starting from the most trivial.
Horizontal Case
In the following mass spring system:

There is no point in regarding gravity (provided that there is no friction in the system).
Vertical Case
The following is the vertical case (from Khan academy ):

Even in this case, there is no point to consider gravity. Following is the explanation.
In this case, as you can see the undeformed spring, will have an undeformed length of L. That will be the point of equilibrium when no mass is applied.
However, when you add a mass m, there is a new point of equilibrium of the oscillations in translated by $L+d$. At that point, the following is true:
$$mg=kd$$
So the equilibrium point is now shifted by d downwards. Let's assume that the choose a coordinate system A that defines displacement 0 at this new equilibrium point.
In general, the net force on the mass at a position y (in the coordinate system A) is given by:
$$\sum F_y(y) = Fs(y)-mg= k(d-y) - mg$$.
When the mass is at the equilibrium point then spring force and gravity are equal, and the net force is zero (see $mg=kd$ above) .
When you move the mass upwards at +y, then the spring force will be reduced, slightly. So the weight will overcome the spring force and the object will accelerate downwards. In that case the net force will be:
$$\sum F_y(y) = Fs(y)-mg= k(d-y) - mg = kd-ky - mg $$
After grouping terms together forces dependent on y and constant forces:
$$\sum F_y(y) = -ky +(kd- mg)= -ky$$
The same happens when you move y downwards.
So as you can see, even in this case the gravity PLUS a Hookean spring act just as one Hookean spring. That is why its safe to disregard gravity.
When Gravity CAN be a driving force.
There is (at least) one way that Gravity can be a driving force. That is the case of a pendulum.

Although this is not a typical mass spring system, it can be modelled as one after linearisation. i.e. the equations of motions of the pendulum without linearisation is:
$$\frac{d^2\theta}{dt^2} + \frac{g}{L}\sin\theta = 0$$
After linearisation (i.e. $\sin \theta\approx \theta$, as $\theta$ approaches 0):
$$\frac{d^2\theta}{dt^2} + \frac{g}{L}\theta = 0$$
This is very similar to the mass spring system. In this case, $\frac{k}{m}$ is substituted by $\frac{g}{L}$. This is also a harmonic oscillator, although its not a mass-spring system.