The energy level of an atom's valence electrons correspond to its period or horizontal row on the periodic table. Hydrogen and helium, both in the first period, have their valence electrons in the principal energy level n=1. The second period elements, lithium through helium, have their outer electrons in the n=2 level. This pattern continues. For the main group elements which are those in groups 1A, 2A, and 3A-8A (skipping the transition elements) the digit that goes with the group number is also the number of valence electrons. (Group 1A elements have one valence electron, Group 2A have 2, and so on.)
Finding the number and energy level of valence electrons is more complicated for transition metals. They have electrons in d-orbitals that are very close in energy to the s-electrons of the next energy level. In the fourth period, K and Ca have their valence electrons in the 4th energy level (in 4s sublevel). The transition metals following them, Sc-Zn, have outer electrons in the 4s and/or 3d sublevel. Some form ions with charges higher than +2, in which case they are losing both 4s and 3d electrons.