Dear student,
Oxidation number is the number assigned to depict the number of electrons gained or lost by that atom in the compound.
The oxidation number of oxygen in NO2 is -2 which denotes that it has lost 2 electrons in this compound. Oxygen, with the atomic number of 8 has the electronic configuration 1s22s22p​4. In its p orbital, two electrons are unpaired which are very easily removable, so, oxygen loses two p orbital electrons when it combines with N, giving it the oxidation state of -2.
Regards