Can a flame test be used to detect non-metal atoms?
No. The flame test cannot be used to detect non-metal atoms.
A flame test makes use of the fact that different chemical elements have distinct, unique emission spectrums. During a flame test, the chemical salt to be tested is introduced to a flame. Upon heating, the electrons gain energy and become excited, and the salt breaks into constituent metal and non-metal ions. As we know, in a chemical salt, the metal ions are cations (positive) and non-metal ions are anions (negative). The positive metal ions are unstable, and re-gain an electron to become neutral. When this happens, this electron falls from a higher energy state to a lower energy state, resulting into emission of a photon. This photon, which is light of a particular wavelength, is basically responsible for the characteristic flame colour that you see during the test. For example, copper ions turn the flame into a characteristic bluish green colour.
On the other hand, the non-metal ions, which already have extra electron, do not take up more electrons in the process and, consequently, have no role to play in changing the flame colour. Thus, the flame test (that is based on observing characteristic flame colours) can only be used for the detection of metal ions. A range of metal ions can be detected using the flame test. However, there are also a lot of metal ions that do not give a result with flame test. The test also fails when the concentration of metal ions in the sample is very low.