My dog has a bad back and when it starts to bother him, he won't wag his tail either. Like the above post says, I would take him to the vet. Good luck, I hope its nothing serious.
It could possibly be a pinched nerve or a pulled muscle...Definitely take him to the vet, it is obviously hurting him.