I'm glad you had his anal glands removed, if they were causing him problems. I do think he may still have some discomfort from surgery, and yes, I think he may have gotten into the habit of doing this, when his anal glands were bothering him. However, your theory about a possible intestinal parasites or external parasites, could be the key.
Even if you don't see any fleas on him, if he's not on an effective monthly flea preventative like Advantage, Frontline or Revolution, sold at your vet's office and also online (some major pet supply stores carry Frontline now, I think), fleas are always a possibility. Fleas are not the only external parasite possible, because there are microscopic skin mites like demodectic and sarcoptic mites, which cause mange. These are very itchy, and could cause him to exhibit the behavior you observe.
In addition, intestinal parasites, as they pass out of the body with bowel movements, can also cause intense itching. Look at his stool for any small white segments which resemble uncooked white rice, as these would be tapeworms, gotten from ingesting an infected flea. Other intestinal parasites which are virtually invisible to the human eye, are also possible. Check the top area and underside of his tail for any sore or irritation on the skin.
It would be a good idea to bring a fresh fecal sample to your vet for analysis, and also bring your dog in for a re-check on his incision area and any reasonable explanation for his discomfort and seeming upset toward his tail/hind area.
I hope your dog is feeling much more comfortable, very soon!