Potential and kinetic energy

displacement with time
velocity with time

The total energy of the system at any time during the oscillation is equal to the sum of the potential energy and the kinetic energy at that point.

The potential energy depends on the elasticity of the spring and the displacement from the equilibrium position. 
The force constant k is a measure of the elasticity of the spring. 
 
PE = ½kx2

The potential energy is largest when x is equal +X or -X (displacement largest).
The potential energy is zero when x equals 0.
 
The kinetic energy at any point depends on the mass of the oscillating object and its velocity accord to the relationship below. 
 
KE = ½mv2

The kinetic energy is largest when the magnitude of the velocity is greatest (namely when x = 0). 
The kinetic energy is equal to zero when the velocity of the oscillator is zero (namely when x = ±X).

The total energy of the system is equal to the kinetic energy plus the potential energy:  E(system) = KE + PE
 
When x = 0, the total energy of the system equals the kinetic energy because the potential energy is zero.
When x = ±X, the total energy of the system equals the potential energy because the kinetic energy is zero.