Ofloxacin, a synthetic antimicrobial drug, exhibits significant therapeutic potential in combating various bacterial infections. The exploration of ofloxacin's antimicrobial properties and the unique catalytic activity of G-triplex(G3) DNAzymes demonstrate the continuous efforts to develop cutting-edge biosensors for bacterial detection. G3 outperforms G4 due to a short, easily generated and dissociated sequence, which allows G3 multimeric sequences to fold more accurately than G4 ones of equivalent length, resulting in higher activity for the formed G3/hemin. This study constructed a novel colorimetric DNAzyme biosensor based on G3/hemin for ofloxacin in food. Aptamer-functionalized Fe3O4 magnetic nanoparticles acted as magnetic separation and detection probes, while G3/hemin served as DNAzyme. Under the optimum condition, the presence of ofloxacin initiated the catalytic oxidation to yield a colored product to quantify the ofloxacin concentration with the linear range of 50-300 nmol/L. Under the optimized conditions, a limit of detection of 15.25 nmol/L was obtained by directly detecting the fluorescent signals, which shows obvious superiority over the previously reported methods. This method offers the advantages of simplicity, rapid detection, and high recovery rates in standardization experiments involving actual samples such as beef jerky and ham sausage, paving the way for its widespread implementation in the fields of biomedical diagnostics, environmental monitoring, and food safety.