This can be due to constipation. Be careful not to blame or judge (this would just add to the problem) When was the last your 7yr old had a large BM? Little ones do not count. If there is a lot of compacted poop in there, the more liquidy stuff, which is less controllable, can leak out into undies. This happened to my kid 2 yrs ago. I was convinced he needed a therapist but his doc had him do adult doses of an over the counter laxative over the weekend to really clear him out. Then we upped his fresh fruit and veggie intake, decreased his white starch and cheese-- it hasn't happened since. He is 8 now.
When shopping for any grain based food- breads, pastas, cereal and crackers etc, look for a minimum of 3 grams of fiber per serving. 5 grams is ideal but anything less than 3 is LOW fiber and can contribute to constipation. And of course, it;s easy to forget about drinking enough water but staying hydrated can really help too.
Good luck!