I know that flame tests can be used to distinguish between some metal ions, and that the colours come from excited electrons returning to the ground state. My question is, why don't non-metal anions also produce colours? Are their emission spectra in the non-visible range? Is there a simple reason why?
There are two reasons, depending on the anion of interest:
1) For the flame emission of any species, anion or cation, metal or not, to be observable, it must emit light in the visible wavelength range, and most non-metal anions do not do this very strongly.
2) Even if there is some emission from the non-metal anion, in many cases their flame excitation efficiency is very low.
The answer then is the combination of these two things, and the fact that many metals have the opposite tendencies (e.g. high excitation efficiency, strong emission in the visible region of the spectrum), which overrides any weak visible emission from the non-metal anions.
As noted in a comment, this is not always the case, but it is the explanation for this strong trend.