Impacted and infected anal glands, perhaps? It happens to some dogs, and the vet will know what to do, and help you prevent it from happening again. Most dogs' anal glands work fine, but some dogs have to get them expressed by someone periodically.