Carbon-based materials are crucial conductive additive and non-metal electrocatalysts for oxygen reduction reaction (ORR) and oxygen evolution reaction (OER). However, the high potential needed for driving OER usually leads to electrochemical oxidation of carbon-based materials, reducing their catalysis durability. Meanwhile, the weak interaction between carbon-based conductive additive and transition metal oxides, nitrides, sulfides and other compounds that possess electrocatalyst activity affects the performance of the electrocatalysts. Herein, a novel three-dimensional (3D) bifunctional electrocatalyst was prepared by embedding CoO nanoparticles into nitrogen and sulfur co-doped carbon framework (denoted as Co/N/S-CF) through morphology-controlled solid-state pyrolysis. The carbon framework was derived from a morphology-retaining pyrolysis of poly(aniline-co-2-aminothiophenol) precursor, retaining the 3D porous structure of the latter. The embedded CoO nanoparticles improve electrocatalysis durability of the 3D carbon-based framework as CoO has lower OER potential than the electrooxidation decomposition potential of doped carbon materials. Only 1.61 V can attain a current density of 10 mA cm−2. Meanwhile, the catalyst retains the highly efficient activity of N and S co-doped carbon framework towards ORR with an onset potential of about 0.92 V, suggesting that it is a qualified electrocatalyst for ORR. Long-term stability of the catalyst for ORR and OER is superior to the commercially available Pt/C and IrO2. Furthermore, the overpotential between ORR and OER (oxygen electrode activity parameter) of the catalyst is calculated to be 0.796 V, indicating that the catalyst could be a promising bifunctional electrocatalyst for both ORR and OER.