The most common cause of this is impacted or infected anal glands. Dogs have two glands located at 10 and 2 (like a clock) beneath the tail. These glands normally secrete a smelly substance every time that the dog poops. Sometimes these glands don't work well and they get overly full. This can be pretty painful.
Your groomer or vet can express them for you. If they are infected, you will need antibiotics.
It sounds like you need to go ahead and see the vet with him. I think that you are past the point of expressing them.
Let me know if you still have questions.