You'll get a lot of different answers...
For me, because the compass is swung with the pitot heat on, it's always on in flight and off on the ground:
1. on as part of a last-gasp check as I line up on the runway: strobes, pitot heat, transponder.
2. off as part of the after-landing checks before I taxy in.
Tim
(edited to add: off on the ground to prevent overheating and burning out, of course)