What could cause my water tank to leak only when I turn off the main water supply?
By shutting off the water main, there is no way for expanded hot water to be relieved by backing into the main.  This causes over-pressure and either the  pressure relief valve is letting some water out (hopefully into the pan) or the high pressure water is opening a flaw in the tank or a through-hole, such as a heating element, spigot, or water connection.

The water temperature is not held perfectly steady.  It varies up and down by perhaps 20 &deg;F (10 &deg;C) or more.  (Test this by turning the thermostat up and down and notice how far it goes past the current temperature before it clicks.)  If no hot water has been called for awhile, the temperature drifts down to the lower range and remains there most of the time.  Odds are that closing the main valve occurs at a lower water temperature.  The valve closure traps and holds municipal water pressure and then the water heater's next heating cycle builds pressure on top of that.