Does it pop out in just one gear all the time or any gear?
My guess would be worn out dogs on the gear(s). It's not always the teeth that wear out on gears, but the dogs seem to wear faster on some bikes. This could be from improper shifting, bad oil, etc.