Photocatalytic hydrogen production from water using solar energy is a promising approach for addressing the global energy crisis. Traditional semiconductor photocatalysts, such as CdS, face challenges such as high charge recombination rates and limited active surface sites, which reduce their efficiency. To address these issues, a heterostructured composite photocatalyst of P-doped Co3S4 quantum dots (QDs) on CdS (P–Co3S4@CdS) was developed in this study. This composite exhibits significantly enhanced hydrogen production, achieving a rate of 373.56 μL h−1, outperforming pristine CdS by 27 times and P–Co3S4 by 221 times. Furthermore, the P–Co3S4@CdS composite simultaneously produces hydrogen and degrades 12 different dye pollutants in wastewater. Phosphorus doping in Co3S4 facilitates electron delocalization, lowers the energy barrier for hydrogen evolution reactions, and enhances performance. The S-scheme heterojunction between CdS and P–Co3S4 promotes efficient charge separation, whereas phosphorus incorporation increases the electrochemically active surface area, exposing more catalytic sites. These factors collectively improved the charge transfer, enhanced the reduction potential, and improved the hydrogen production efficiency of P–Co3S4@CdS. The results of this study demonstrate the potential use of abundant and low-cost materials (i.e., Co3S4) combined with phosphorus doping for enhanced photocatalytic hydrogen production and oxidative removal of dyes from wastewater.