It's called "coprophagia".
It's a disgusting habit to us, but it is not harmful to your dog if he eats his own feces. However if he eats another dog’s feces, he could get parasites from it if it has been sitting too long. This could happen with your own dogs feces, so be sure to scoop it up as soon as you can.
A way to keep them from eating their own feces is to put meat tenderizer, garlic, or pumpkin powder on their food, this will make their feces unappealing to them.
There are several reasons that dogs eat their feces. It could be from boredom, anxiety or the lack of nutrients in their diet. Be sure that they are fed a high quality natural dog food. Do not buy food that includes by-products, corn, soy, wheat, gluten or artificial flavors or coloring.