He could have impacted/infected anal glands. Very good you will get him to the vet - sooner is always better to remember for the future. The anal glands can blow and rupture. For now, I would use warm - not hot - water compresses with a paper towel or washcloth a few times a day, and try to distract him from licking in a nice way.
I had a foster puppy who was on antibiotics and compresses, and vet visits every week or so to keep an eye on his when they got impacted/infected.
If it's not that, it could be fistulas, which are a whole different story, or probably a lot of other things I've never seen. Good luck!