Let Q0 be the initial charge on the capacitor. Then,
Q0 = CV
The charge on the capacitor at time t after the connections are made,
Heat dissipated during time t1 to t2,
Time constant = RC
Putting t1 = 0 and t2 = RC, we get:
Alternative method:
Heat dissipated at any time = Energy stored at time 0 − Energy stored at time t