Yes, having a small bite to eat afterward or taking an antacid might help counteract increased release of digestive juices after orgasm. As far as your worry about masturbation, are you aware that almost 100% of males do so & probably close to 80% of females do, although usually less frequently than guys? EVen people in relationships or marriage continue to do it. It's so universal that Medical Dr's, Psychologists & Sociologists consider it entirely normal &it even has some proven health benefits. No reason to stress about this. Some societies & religions hold onto outdated ideas about the 'evils' of this practice, but even the Bible doesn't condemn it (Onan's sin was NOT masturbation, rather it was pulling out to avoid impregnating his deceased brother's wife). Just relax! It's possible your digestive problems are the direct result of you feeling unnecessarily guilty about it. If you can learn to accept this as normal & not stress about it, you may find you no longer have these digestive issues...
I highly doubt your masturbation is related in any way to your digestive problems. If your regular Dr can't find a solution, it might be time to see a Gastroenterologist. He/she might be able to run some tests (Upper and/or Lower GIs, measure transit times, etc.) to diagnose your issue. Almost everyone masturbates, some several times a day, so if that were responsible for digestive problems, there'd be millions upon millions of guys (& some women) complaining of GI symptoms!