What do metals typically do when they become ions? What about nonmetals?

Sodium, a metal, loses its single valence electron so that the next lower energy level becomes its valence shell with 8 electrons. Losing the single electron gives the sodium ion a ${1}^{+}$ charge.
Oxygen, a nonmetal, has 6 electrons in its valence shell, so it gains 2 electrons and forms a ${2}^{-}$ ion, now with 8 valence electrons.