Problem about a spring which oscillates due to a external force 
A person holds a spring  of stiffness $k= 80$ N/m by its extremity A; In the other end there is a mass of $0.5$ kg. The spring is initially at equilibrium, when the person starts to shake the extremity $A$ making it oscillate with amplitude of $5$cm and period of $1$s.
  Derive the equation which describes the motion of the extremity $B$.


How I was trying to solve it
As the system is at equilibrium in $t = 0$, the hand in $A$ already exerts a force:
$F_{0} = mg$
As the person starts to shake the hand, the extremity $A$ will have a motion $x_{a} = A cos (\omega t + \varphi )$, where $A = 5$cm, so
$F(t) = F_{0} + kx_{a} = mg + Akcos (\omega t + \varphi )$
As $F(0) = F_{0}, \varphi = -\pi/2$
If $x_{b}$ is the motion of the extremity B, we would have the O.D.E:
$$m \ddot x_{b} = mg - kx_{b} - (mg - kA\sin(\omega t) )$$
Dividing both sides by $m$ and letting $k/m = \omega_{0}$ would give, finally,
$$ \ddot x_{b} + \omega_{0} x_{b} = A \omega_{0} \sin(\omega t)$$
I would like to know if what I'm doing is correct... I'm not very confident about the principle behind this... Is the system described a sort of forced harmonic oscillator?
 A: Your assumption that the force at A is equal to $mg$ is not correct. It might have been correct if the entire system was in equilibrium. Then you would have been justified in using the principle of equilibrium. However, this is a dynamic system, and you have to apply Newton's 2nd Law instead.
To solve this problem, let us define three variables, $x$, $y$ and $z$. Let $x$ be the downwards displacement of point A from its original location, $y$ be the downwards displacement of point B from its original location if no mass was added, and $z$ be the displacement of B from the original equilibrium location with the mass added. It turns out, from principle of equilibrium that $z = y - \frac{mg}{k}$. As a linear system analysis, $x$ will be the system input (This is the thing thats oscillating at 5cm with period 1s), and $z$ will be the system output (This is what your answer will be).
So, let us consider the forces acting on the mass: you have two forces: the force due to the spring and the force due to gravity. We can determine the force due to the spring from Hooke's Law:
tensile force = spring stiffness $\times$ extension.
At any point of the vibration, the spring will either be extended or compression. Let's imagine the case where the spring is in extension. If the spring is extended, this means that $y$ is bigger than $x$. Therefore, the spring extension is equal to $y-x$. Also, when the spring is extension, this causes the spring to try to pull the mass upward. So, this means we have an upward force of $k(y-x)$ acting on the mass due to the spring.
If we now consider times where the spring is in compression, the length compression of the spring is equal to $k(x-y)$, as $x$ is now bigger than $y$. The force due to the spring is compressive, so therefore is acts downwards on the mass. So, in compression, the spring exerts a downward force of $k(x-y)$, which is exactly the same as an upward force of $k(y-x)$. So, regardless of whether the spring is in tension or compression, the spring will exert an upward force of $k(y-x)$ on the mass.
So we know the forces acting on the mass: spring force (upwards, $k(y-x)$), weight (downwards, $mg$). So, apply Newton's 2nd Law on the mass. Note that $y$ describes the position of the mass, and since $y$ is positive for downwards displacement, then $\ddot y$ (the acceleration of $y$) is positive downwards.
$$F_{resultant} = ma$$
$$mg - k(y-x) = m\ddot y$$
$$\therefore \ddot y + \frac{k}{m}y = g + \frac{k}{m}x$$
So, we know $x$ as a function of time,
$$x = x_0 \sin(\omega t)$$
So, you have the equation:
$$\ddot y + \frac{k}{m}y = g + \frac{k}{m}x_0 \sin(\omega t)$$
Now, as will become clearer later on, we will define the resonant frequency as $\omega_n = \sqrt{\frac{k}{m}}$. Also, substitution in $z$ to get rid of the gravitational term:
$$\frac{\ddot z}{\omega_n^2} + z = x_0 \sin(\omega t)$$
If you solve this equation, assuming the system is initially at rest, you get:
$$z = \frac{x_0}{1-\frac{\omega^2}{\omega_n^2}}\left( \sin(\omega t) - \frac{\omega}{\omega_n} \sin(\omega_n t)\right)$$
Let's look at a few graphs for your example in particular. $\omega_n = 12.65 rad\cdot s^{-1}$ and $x_0 = 5cm$.
For $\omega/\omega_n = 0.5:$

For $\omega/\omega_n = 0.75:$

For $\omega/\omega_n = 1:$

For $\omega/\omega_n = 2:$

As you can see from graph 2, when you supply an input vibration at a frequency equal to the harmonic frequency, the system gains more and more energy. Here, the system appears to gain amplitude unto infinity. However, as we all know, this cannot be physically possible. This is because, in reality, you get damping forces, such as air resistance, which causes mechanical energy to be dissipated from the system, analogous to heat dissipation in a resistor in an electric circuit. In such a system, the amplitude would reach a maximum value at some point, rather than tends to infinity with time.
Here is a graph to show the maximum amplitude obtained for particular values of $\frac{\omega}{\omega_n}$:

