If you know your dog ingested something that is toxic or bad for him or her, then yes you should feed the dog some canned pumpkin or dry toast because this will help the dog puke the bad stuff up or digest it.
The first thing you should do when your dog has an upset stomach is not feed him pumpkin. You want to remove all food for a good 10 hours, to help him to clear the bad matter out of his intestines.