A fully microscopic theory of electron spin relaxation by the Dyakonov-Perel type spin-orbit coupling is developed for a semiconductor quantum well with a magnetic field applied in the growth direction of the well. We derive the Bloch equations for an electron spin in the well and define microscopic expressions for the spin relaxation times. The dependencies of the electron spin relaxation rate on the lowest quantum well subband energy, magnetic field and temperature are analyzed.