How do I know with which oxidation numbers I can form a certain kind of compound?
You need to be familiar with some of the compounds earlier, otherwise you can't tell if it exists. Remember facts come first before explanation. It also depends usually on the atom/ion to which it is bonded. for example since Fluorine is most electronegative it can form $\ce{XeF6,XeF4}$,etc. but $\ce{XeH3}$ doesn't form also oxygen forms large oxidation states as it is electronegative too and there is also more energy released as many bonds are formed (ususlly pi-bonds.)