When an electron in any element absorbs energy it will be promoted to an excited state. How much energy we supply determines how many \ which excited states will be created. As the electron returns from these various excited states to the ground state light can be emitted, this is the basis of atomic emission spectroscopy.
In the case of sodium (or any other atom with just one valence electron) many excited states are possible, so many emission lines are observed. However, a very likely transition will be the one from the s orbital to the next highest energy orbital, the p orbital.
The magnetic energy of an electron spin is split into energy states with different total angular momentum due to the electron spin's interaction with the internal magnetic field set up by the orbital motion of the electron, this is termed spin-orbit coupling. In the case of a p orbital, it is split into two states (the total angular momentum j is given as j = l +/- s, where l is the angular momentum quantum number [l=1 for a p orbital] and s is the electron spin (1/2), therefore j has two values or states for an electron in a p orbital, 1/2 and 3/2). It is the light emission that occurs when the excited electron returns from these two p orbital energy states to the s orbital ground state that produces the doublet seen for all atoms with a ground state involving one electron in an s orbital.