Food may be too large
Bettas often grab food and spit it out if the piece is too big or hard. Try smaller pellets or soften dry foods briefly.
The food may be unfamiliar
Some bettas need time to recognize a new food. Change foods gradually when possible.
Check the tank too
If spitting food comes with lethargy, hiding, clamped fins, or other symptoms, test water and look for stressors.