A 2-gallon is a bit small for a betta so I'd upgrade if you have the space (a 5-gallon shouldn't take up much more space than a 2-gallon and it'd be MUCH more appropriate).
As the above poster stated, you probably have some build up of ammonia or nitrates due to the infrequent water changes. When I kept my bettas in 2-gallon aquariums (I don't anymore after seeing how well they did in larger tanks) I did weekly full water changes...or at least 50-60% changes if I was in a rush that day. Your algae problems are being caused by this as well and I would stop adding the anti-algae stuff (it probably doesn't work, to be honest) and instead step up your water changes
. Make sure you're cleaning the gravel well since that's where waste builds up and breaks down into ammonia.
What kind of pellets are you feeding? Even if you were feeding the tiniest pellets (New Life Spectrum or HBH Betta Bites) that sounds like way too much. He should only be eating a few a day (the exact number depends on brand). I usually feed my bettas four or five times a week instead of every day. Supplementing with live or frozen foods is a good way to keep things moving in his digestive system, too. Some examples of what I feed are fruit flies, bloodworms, blackworms, brine shrimp, freshwater mysis shrimp, chopped earthworms, and pinhead crickets.
I'm guessing he's not feeling well due to a combination of too much food and polluted water (it's probably not terrible or anything so don't feel bad...but more water changes will really help!). Luckily, that's an easy fix
P.S. Do you have any pictures? We love pictures around here and it's always awesome to see a betta that's well cared for!