The valence electrons of magnesium, which has an atomic number of 12, are located in the 3s orbital.
In an atom, electrons are arranged in shells surrounding the nucleus. The innermost shell, the 1s orbital, holds the electrons closest to the nucleus and is usually filled first. The next shell, the 2s orbital, is further away from the nucleus and is also filled before the third shell, the 3s orbital.
In the case of magnesium, it has 12 electrons, and so the first two shells are completely filled. The 3rd shell, which is the valence shell, has only two electrons in the 3s orbital. These are the valence electrons, and they are the electrons that are involved in chemical reactions and bonding with other atoms.