Photocatalytic H2O2 production via oxygen reduction reaction (ORR) is of great interest. However, the inferior charge transfer efficiency and the low 2e− ORR selectivity grossly constrain this process. Herein, we incorporated pyrimidine (PM) groups as linkers between heptazine units into the poly(heptazine imide) (PHI-PM). There was an augmented in-plane built-in electric field leading to elevated charge separation and transfer capabilities. Additionally, the incremental electron sink effect by PM groups prolonged the charge lifetime and fostered an efficient transfer of electrons from PM groups (electron trapping center) to −C≡N groups (oxygen adsorption center), significantly improving the activity and selectivity of 2e− ORR. Results indicated that the optimization of charge transfer greatly increased the proportion of two-step single-electron ORR, accelerating the reaction kinetics. Meanwhile, side-reaction 4e− ORR was inhibited attributed to the selective generation of •O2−. This work paved new avenues for regulating the pathway of photocatalytic ORR for H2O2 production.