Oxidation number, also called Oxidation state is the total number of electrons that an atom either gains or loses in order to form a chemical bond (Ionic bond).
Sodium (Na) and Magnesium (Mg) are metals and they donate electrons to form bonds, which is why they have the positive oxidation state.
Chlorine (Cl) being a non-metal acts an electron acceptor and has a negative oxidation state.
Helium (He) being a noble gas has 0 oxidation state as it has stable electronic configuration and it does not form compounds which means it neither gains nor loses electrons.