Let's take a look at a table of standard electrode potentials and find the relevant half-reactions:
Reductions (there is also a half-reaction for water reduction that doesn't involve a proton at -0.83 V, but for the sake of simplicity, we can ignore it):
$$\begin{align*}
&\ce{Na+ + e- <=> Na} & &E°=-2.71\ \mathrm{V}\\
&\ce{2H+ + 2e- <=> H2} & &E°=0\ \mathrm{V}
\end{align*}$$
Oxidations (reduction reactions reversed):
$$\begin{align*}
&\ce{2H2O <=> O2 + 4H+ + 4e-} & &E°=-1.229\ \mathrm{V}\\
&\ce{2Cl- <=> Cl2 + 2e-} & &E°=-1.36\ \mathrm{V}
\end{align*}$$
Now, if you know the concentrations of the species involved, you can use the Nernst equation to figure out the actual potentials, but we can reason around it without knowing the exact numbers.
The big thing to notice is how close the potentials of each of the reductions and oxidations are to one another—the reduction reactions are separated by almost 3 V, but the oxidation reactions are very similar. This means that for reduction, it is far less energetically costly to produce hydrogen gas than to reduce sodium, and in fact, if any sodium were produced, it would instantly react with the water to produce hydrogen gas, so if there is any water around, that half-reaction will be favoured. In the real world, the exact potential hydrogen is produced depends a great deal on the electrode used (see overpotential), but it's more or less impossible to electrodeposit metals with much lower reduction potentials than zinc in aqueous solutions. To actually produce metallic sodium, electrolysis of molten NaCl without any water present is the most common method.
Looking at the oxidations, the story's quite different. It doesn't take much more energy to oxidize chloride than it does water (and if the chloride concentration is high, the oxidation potential will go up). This means that (subject to the effects of the electrodes on overpotential), some amount of both half-reactions will occur and because chlorine is a gas and therefore leaves the solution and the oxidations potentials are so close (leaving little energy to overcome kinetic barriers), the chlorine produced will not significantly oxidize the water.