The non-metallic doped g-C3N4/MoS2 (X/g-C3N4/MoS2, X = O, F, Si, P, S, and Cl) heterojunctions are designed by the First-principles. The electronic, optical properties, and the effect of the electric field on the band structure of the X/g-C3N4/MoS2 heterojunctions are investigated. The O/g-C3N4/MoS2 heterojunction is a semiconductor (1.340 eV, Type-II), and the F, Si, P, S, and Cl/g-C3N4/MoS2 heterojunctions exhibit metallic properties. The built-in electric fields generated at the interface enhance the separation efficiency of the photo-generated electron hole pair. Further, the band structures are controllable by the electric field, especially, the band structure of the O/g-C3N4/MoS2 heterojunction changes from semiconductor to metallic properties (0.4 V Å−1), while that of the S/g-C3N4/MoS2 heterojunction changes from metallic to semiconductor properties (−0.4 V Å−1 and −0.2 V Å−1). In the meantime, the visible light absorption coefficient is enhanced, especially, the Si/g-C3N4/MoS2 heterojunction has an absorption peak of 1.188 × 105 cm−1 at 625.8 nm. Furthermore, the O/g-C3N4/MoS2 heterojunction can occur photocatalytic water decomposition under acidic conditions.