It's funny, I actually did a mini-report last semester on this topic 
I haven't noticed it in either of my annies, but I have in a couple of my blood pythons. One of my bloods, a WC female, does this invariably as her first line of defense. She will wag her tail, then begin to produce urine and urates, and then finally strike and try to bite.
At the time I wrote the report, I was wondering if it may be somehow related to the caudal luring behavior seen in many snakes -- perhaps instead of luring prey to the tail, it instead lures predators away from the head..? There are a number of snake species that have tails that look like their heads, and will present their tail to a predator as their defense mechanism.
Kelly's idea that it aids in urination/defecation is a lot simpler, though -- I guess one way to test this might be to watch a snake passing urates when it is calm, and see if it still wags its tail.
-----
-- Kitt