Utilizing p-n composite materials for the fabrication of metal-oxide semiconductor (MOS) gas sensors represents a promising strategy to achieve exceptional selectivity in detecting reducing gases such as hydrogen (H2) and carbon monoxide (CO). However, previous studies have typically achieved this selectivity under fixed operating temperatures and single molar ratios. This study presents the successful synthesis of n-In2O3/p-Co3O4 nanoparticles, featuring a p-n heterojunction structure, using a simple composite preparation method. The gas-sensing properties, crystal structure, morphology, and chemical states were comprehensively characterized using an electrochemical workstation, XRD, TEM, HRTEM, and XPS. Experimental results show that the gas sensor responses of the n-In2O3/p-xCo3O4 composites (with x = 10.5, 15, 18, 21), annealed at 500 degrees C within an operational temperature range of 350 degrees C to 400 degrees C, exhibit distinct behaviors for CO and H2 gases. This addresses the challenge of achieving selective detection across varying conditions. Notably, the n-In2O3/p-18Co3O4 composites display opposing response characteristics for both gases across a broad temperature range of 200 degrees C to 400 degrees C. At 350 degrees C, the n-In2O3/p-18Co3O4 sensor demonstrates optimal selectivity, significantly minimizing cross-sensitivity and improving detection accuracy and reliability. The sensor also shows excellent stability, with consistent responses under repetitive exposure conditions. By improving both sensor selectivity and stability, this research advances gas detection technologies, with potential applications in sustainable energy and public health monitoring.