What happens when we earth the circuit as shown below, why should it matter? because potential at a point is relative? So if the earlier potential was $V_p$ at that point, it becomes $0$, so every potential becomes $V-V_P$ but the potential difference remains constant, so charge should remain constant and hence no heat should be released. Please help only in this conceptual doubt.
If there were no other absolute voltage references in the problem, then you would be correct. But there is already a connection to ground on the upper trace of the diagram. The voltage of that trace does not change (it starts at $0$ and remains $0$ after closing $S$).