Your dog is painful around the tail base. This could be from an injury to the tail, back injury, wound, or anal gland infection. I would have your dog examined by a veterinarian so the cause of the discomfort can be found and appropriate treatment/pain medication can be initiated.