The correct answer is B. They have valence electrons in the same energy level.
Nitrogen (atomic number 7) and oxygen (atomic number 8) are both in Period 2 of the periodic table. This means they have their valence electrons in the same energy level (the second energy level). Nitrogen has 5 valence electrons, while oxygen has 6 valence electrons, so they do not have the same number of valence electrons (thus option C is incorrect). They also do not have the same number of electrons (option D is incorrect). They are in the same period, so they share the same energy level for their valence electrons (thus option A is incorrect).