Maximum charge of the capacitor= Q
So total energy of the circuit `=1/2Q^2/C`
When the charge of the capacitor is q, then energy stored in the electric fields is `1/2q^2/C`.At this stage energy stored in the magnetic field is `1/2Li^2`.
If it is equal to `1/2q^2/C`, then total energy
`=1/2q^2/C+1/2Li^2=1/2q^2/C+1/2q^2/C=q^2/C`
So, `q^2/C=1/2Q^2/C`or,`q^2=Q^2/2` or, `q=Q/sqrt2`