P.M.
I've known only a couple of parents whose kids did this. It seemed to work to just separate the child from the poop with the calm instruction "This is not food. Poop is not for eating. Let's go get cleaned up." Or similar, just like you'd take a CD or a cell phone away from a toddler with calm instructions. Repeat as often as necessary.
It's not a good idea to try to instill disgust or horror of a natural human product, especially because this could create unexpected side effects later on, like fear of wiping oneself.
Patience, and good luck. Your son could just be satisfying simple curiosity, in which case I'd give him other alternatives to explore, like clay or finger paints. If he persists, it could indicate some dietary imbalance that he's trying to meet, so talk to your pediatrician.