It sounds like your dog has an abscessed anal gland. This can be very painful to the dog. Your dog is licking it trying to express it. This has happened to my dog before in the past. You probably need to take your dog to the vet, if it's not too inflamed your vet may be able to express the gland in the office, but if your vet is unable to express the gland he/she will give you an anti-inflammatory medicine and possibly a few pain pills and more than likely an anti-biotic in case of infection. Smaller dogs should have their anal glands expressed when they are groomed. Larger dogs don't have this problem typically. When you see a dog scooting on the floor a lot of times this is what they are trying to do.