The problem that you are describing is called "flatulence", which is excessive formation of the gases in the stomach or intestine. There are many different causes of chronic flatulence in dogs, and some of them include:
1)Increased aerophagia (swallowing of air)
This can be due to--
-Fast eating (gluttony)
-Respiratory disease or any cause of increased respiratory rate
-Feeding shortly after exercise
-Brachycephalic breeds of dog (Boxer, Bulldogs, Pugs, etc...)
-Diets high in nonabsorbable oligosaccharides--soybeans, peas, beans
-Diets high in fermentable fiber--lactose, fibrin, psyllium, oat bran
-Abrupt changes in diet
-Spices and food additives/supplements
-Acute and chronic intestinal disease
-inflammatory bowel disease (IBD)
-small intestinal bacterial overgrowth (SIBO)
4) Flatulence also seems to be common in very sedentary pets. The more exercise that a pet gets, the less likely that they are to have problems with gas.
Since your dog has had this problem chronically, you really should have him in to the vet for a physical examination. You should bring a stool sample with you so that he can be checked for parasites, as this is certainly a possible cause of chronic gas.
Also, since you mention that your dog has chronic loose stool, I am most suspicious of Inflammatory Bowel Disease or Small Intestinal Bacterial Overgrowth.
Once the underlying cause for you dog's chronic gas problem is ascertained, then an appropriate course of action can be taken to stop it from being produced.
I am attaching a client information sheet that I use in my practice that discusses the causes of flatulence in dogs and the common treatments that are used. I am also attaching information about both IBD, SIBO and causes of chronic diarrhea. I hope that you find them useful.FlatulenceDiarrheaIBDSIBO
I hope that this information is of help to you, and I wish you the best of luck with your dog. Please let me know if I can be of further assistance.