Does the number of valence electrons an element has change?
Yes, if you are referring to chemical process, but each element has a specific number of 'ground state' valence electrons because of its nuclear composition.
Yes, during chemical process there is the 'Octet Rule' => Elements gain or lose electrons at the valence level to achieve a Noble Gas configuration. The element that violates the 'Octet Rule' in the Main Group Elements is Hydrogen => Noble Gas configuration of Helium. Loss of valence level electrons in Transition and Inner Transition Metals leads to 'Pseudonoble' Gas configurations that could have more than 8 electrons.
In the Quantum Theory of the elements, the valence level is defined as the highest principle quantum number of the electron configuration of that element. Lower energy quantum numbers are part of the 'core' structure of the element and resist gains or losses of electrons during ordinary chemical or physical process.
Oxygen (O) => The ground state configuration is
Sodium (Na) => The ground state configuration is
The Transition metals are prone to lose valence electrons from the highest energy level first, but in some cases will be lost from lower energy d or f-orbitals during chemical processes.
The details of this issue is a bit more involved than what is referenced in this post, but should give a relative idea of the fundamentals.