A photoelectrochemical (PEC) aptasensor for sensitive and selective detection of oxytetracycline (OTC) was designed and constructed based on a novel Z-scheme heterojunction of bismuth sulfide-carbon nitride (Bi2S3-C3N4) as photoactive material. Since the photogenerated electron-hole pairs can be effectively separated by the Z-scheme route, the photocurrent intensity of the constructed Bi2S3-C3N4 heterojunction was about 2.0 times higher than that of pure Bi2S3. Specifically, we disclosed that the increased photocurrent of the aptasensor with the target OTC was ascribed to the oxidation by the generated holes in the Bi2S3-C3N4 based PEC system, which was further validated by electron spin resonance technique. Under the optimized experimental conditions, the photocurrent gradually increased with the increasing of OTC concentration, the proposed PEC aptasensor has the advantages of satisfying linear range (from 1 ×10−12 to 1 ×10−6 M), low detection limit (6 ×10−13 M), excellent selectivity, reproducibility, and stability for OTC detection. In addition, the designed PEC aptasensor has been successfully used for the detection of OTC in soil samples.