There are two equations of motion: You have one prior to collision and after collision. It's somewhat unclear what you are trying to do, but if you are trying to obtain the equations of motion after collision, you would want to follow the steps:
calculate the new momentum using ${p_{obj1}} + {p_{obj2}} = {p_{obj1\& 2}}$.
calculate the velocity from the momentum using $p = mv$ where $m$ is the total mass
calculate the kinetic energy using $T = 0.5mv^2$
you know the spring potential energy is $V = 0.5kx^2$. Assume all kinetic energy is is applied to the spring and converted to potential energy. This means that you have a situation before compression and after compression:
Before
$T_{before} = something$
$V_{before} = 0$ (assuming the spring is at equilibrium at the time of impact)
After
$T_{after} = 0$ (it is no longer moving)
$V_{after} = something$
Given that you now know $V_{after}$, you can simply use $V_{after}=0.5kx^2$ and solve for x being the distance from the spring equilibrium (i.e. the compression).
If you have expressions for both energies T and V, you can express fully the equations of motion, although I'm not sure that's what you are supposed to do in this assignment.
The above method is the energy approach, which you would usually use.
Kinematics (approach using the equations of motion):
Edit: No, you can't use $ma = kx$ and simply solve for x. You should consider both the acceleration and x as functions of time.
By stating $ma = kx$ you obtain the equations of motion
\begin{array}{l}
\ddot x\left( t \right) = - \frac{k}{m}x\\
x\left( t \right) = A\sin \left( {t\sqrt {\frac{k}{m}} } \right)
\end{array}
$x(t)$ can be found to be the solution where A is the oscillation amplitude (how compressed the spring becomes)
Edit2 (more help):
Obtain the derivative of the solution, and have it be the initial velocity
$$\dot x\left( 0 \right) = v_0$$
You should be able to obtain the result from this equation.
I should probably stress that you would usually use the energy or "work" approach for solving this kind of tasks. But it can be done using the equations of motion in this case because $x(t)$ is analytical.