Pesticides widely used in modern agriculture can impact on the environment and human health and hence it is important to develop highly sensitive detectors for pesticide residues. Optical methods based on photoluminescence (PL) properties provide an ideal approach to facile and accurate trace-level analysis of pesticides. Carbon Quantum Dots (CQDs) have been proposed as the photo-sensitizer for this purpose, however the optical properties of pure CQDs restrict the detection limit of such an approach. Doping is an effective strategy to introduce novel electronic structure into the CQDs to solve this problem. Here, using ionic liquids as a single source, novel N and S co-doped CQDs were obtained by a simple ultrasonic method. The doping in the structure introduces localized states which can trap photo-excited electrons and enhance their PL lifetime. These quantum dots are successfully used as the basis of a simple, efficient sensor for ultrasensitive pesticide detection (Limit of Detection = 5 ppb). Application of the analysis method to real fruit samples is demonstrated. The mechanism of the high sensitivity is also investigated and explained from experimental and calculation results.