What is the food you are feeding? If pellets, how many?
Does his stomach look to be bulging or just turning pale in color?
You could try fasting him for a day or two to see if that helps improve his stomach. another good option is to do a partial water change. I recommend about 50% since a 2 gallon tank is best kept with 1 50% and 1 100% weekly.
I filter can help a little bit with this, but it will not eliminate ammonia, nitrates, and nitrites.
This is a sign of stress not necessarily stomach issues. At the very least he is too cold. Bettas need to be kept at a constant temp between 76-82 ideally in the 78-79 range. 2g is large enough for a heater. I use Marineland Visitherm 25w in something that small but there are probably others as well. Also need to invest in a cheap submersible glass thermometer. Tank temp will be several degrees below room temp so if your room temp is 72 your betta is freezing.
What conditioner are you using for the water? And a 2g should be changed several times a week. I'd do maybe two 50%s a week and one 100%. At the very least change 100% every 3-4 days but there will be at least small traces of ammonia present at that point