Quantization of electromagnetic field in isotropic dielectric medium occupying a half space is carried out. For a dielectric having a plane boundary with vacuum, we have constructed a complete orthonormal set of light waves propagating in a whole space. Using this set we calculated the rate of spontaneous emission of photons by electrons in quantum dots and quantum wells. We predict oscillations of photon emission rate as a function of the distance between a quantum nanostructure and the surface.