The Mg-doped inside of LaCoO3 lattice and heterojunctions between MgO and LaCoO3 were acquired synchronously through a sol-gel preparation. Significant enhancement in photocatalytic degradation of rhodamine B (RhB) was obtained on the modified catalysts, with the degradation ratio of RhB reaching as high as 98% within 3 h under the experimental conditions, and the quasi-first-order rate constant of the RhB degradation reaction over the modified LaCoO3 reaching almost 4.5 times of the pristine one. The as-prepared catalysts were characterized by X-ray diffraction (XRD), N-2 adsorption-desorption at low temperature (BET calculation), scan and transmission electron microscopy (SEM, TEM), Fourier transformed infrared spectroscopy (FT-IR), X-ray photoelectron spectroscopy (XPS), UV-Vis diffuse reflectance spectroscopy (DRS) and photoluminescence spectroscopy (PL). The results indicated that about 10% of Co3+ in LaCoO3 can be substituted by Me2+ while its perovskite-type structure remains unchanging. The moderate Mg-doping improved the photocatalytic performance of LaCoO3 by the donor level of impurities, derivation of Co4+ and adsorption of dissolved oxygen. The over Mg-doping suppressed the degradation of RhB for the recombination of photogenerated carriers on impurities. An optimal amount of MgO cooperates harmoniously with LaCoO3 in degradation of RhB by offering high surface area for the enrichment of RhB, abundant superficial hydroxyls for trapping of electrons and derivation of hydroxyl radials, as well as, enhancing the light quantum efficiency through trapping electrons on vacancies of lattice oxygen and migration or jumping of electrons between MgO and LaCoO3.