The present invention includes forming an optical guide layer on a substrate, forming a cap layer on the optical guide layer, and forming openings in parts of the optical guide layer and the cap layer to form a diffraction grating from part of the optical guide layer. The substrate is heated to a temperature less than a growth temperature of the cap layer and equal to at least a temperature at which mass transport of the cap layer occurs to cover, with part of the cap layer, the lateral faces of the optical guide layer exposed by the openings. A burying layer burying the diffraction grating is formed on the substrate, after the mass transport.