It is an efficient strategy to construct photocatalysts by integrating the advantages of inorganic semiconductors and covalent organic frameworks (COFs) for H2 generation along with simultaneous organic oxidation. Herein, an inorganic/organic CdS/COF (denoted as TpBD) 2D heterostructure is fabricated by an electrostatic self-assembly method. The ultrathin 2D structure can reduce charge transfer distance, enhance light absorption, and multiply reaction sites while the S-scheme heterojunction improves the charge separation efficiency. The CdS/COF composite acquires an outstanding photocatalytic activity of 15.1 mmol/g/h, and can simultaneously convert cheap ascorbic acid to value-added 2,3-diketo-L-gulonic acid. The Hall effect test elucidates the dynamics of carrier migration. The electron paramagnetic resonance analysis, photo-irradiated Kelvin probe force microscopy, femtosecond transient absorption spectroscopy, theoretical calculation, and in-situ irradiation X-ray photoelectron spectroscopy measurements confirm the superiority of S-scheme heterojunction for charge carrier transfer. This research presents new inspiration to develop efficient photocatalysts for hydrogen production and green chemical production.