have him smack you when ever you start doing it.
if the teacher is a woman, and if that woman is valentina lisitsa that approach would fail miserably...in my case i would develop several problems to get constantly smacked...
when i play my head starts drifting to the piano and my teacher says its very bad for my shoulders what do i do to stop
Not if she uses a 2x4!
To get back on topic: this is an issue of posture, and what I would do in this situation is exercises for the back and neck to strengthen them, and I'd try to work on keeping proper posture at all times while sitting.
By the way a 2x4 is a wooden piece of wood that it appx 1.5 inches by 3 inches.
By the way a 2x4 is a wooden piece of wood