$x(t)$ does not instantaneously go to infinity; the case $\omega=\omega_0$ needs special care. I think an answer directly from the math will help. The driven SHM equation of motion is
$$\tag{1}
x''+\omega_0^2x=\cos(\omega t)
$$
Where I have set all other constants to unity. The general solution of (1) is equal to the homogeneous plus any particular solution
$$
x(t)=x_H(t)+x_P(t)
$$
The homogeneous solution is simply
$$
x_H(t)=C\sin(\omega_0 t)+D\cos(\omega_0 t)
$$
Where $C$ and $D$ are determined by the initial conditions. Note that the amplitude of $x_H$ is fixed for all time by the constants $C$ and $D$. To find a particular solution, I will use undetermined coefficients. Starting with the ansatz
$$\tag{2}
x_P(t)\stackrel{?}{=}A\sin(\omega t)+B\cos(\omega t)
$$
We substitute (2) into (1). If we can consistently solve for the constants $A$ and $B$, then we are done. When $\omega\neq \omega_0$, the result is
$$
A=0\\
B=\frac{1}{\omega_0^2-\omega^2}
$$
Which corresponds to the solution in OP. However, when $\omega=\omega_0$, there are no $A$ and $B$ that make (2) a solution of (1). Try it and see! In this case, we must modify the ansatz (2) to read
$$\tag{3}
x_P(t)\stackrel{?}{=}At \sin(\omega_0 t)+B t\cos(\omega_0 t)
$$
This is a standard procedure with undetermined coefficients: when the homogeneous solution has a term that is equal to the RHS of (1). Substitute (3) into (1) and solve for $A$ and $B$, which yields
$$
A=\frac{1}{2\omega_0} \\
B=0\\
\therefore x_P(t)=\frac{t \sin(\omega_0 t)}{2\omega_0}
$$
Therefore: the particular solution is an oscillating function with amplitude that grows linearly in time. This conclusion follows only from the differential equation (1) with no other physical input or hand-waving.
Edit: With the general solution
$$\tag{4}
x(t)=C\cos(\omega_0 t+\phi) + \frac{F_0}{m}\frac{t}{2\omega_0}\sin(\omega_0 t)
$$
in hand, we may answer your question about the relative phases of the spring and driving force. I've reinstated units and written $x_H$ in a more convenient, equivalent, form. The spring force is
$$
F_{\text{sp}}(t)=-k x(t)
$$
If $C\ll \frac{F_0 t}{\omega_0 m} $ (large times) then the second term on the RHS of (4) is large compared to the first. So we can write approximately
$$
F_{\text{sp}}(t)\approx-\frac{F_0 t}{2}\sin(\omega_0 t) \qquad ;\qquad C\ll \frac{F_0 t}{\omega_0 m}
$$
While the driving force defined in (1) is $F_0 \cos(\omega_0 t)$, compare the $\sin$ to the $\cos$. So for large time, the driving force is approximately $\pi/2$ out of phase with the spring force.