With the increase of drug‐resistant bacteria and the limitations of traditional antibacterial methods, photocatalytic inhibition has received widespread attention as a novel antibacterial method. In this paper, poly(1‐vinyl‐3‐ethylimidazolium tetrafluoroborate) composite oxygenated carbon nitride (PBF‐OCN) were prepared by in situ free radical polymerization using 1‐vinyl‐3‐ethylimidazolium tetrafluoroborate and OCN. The results showed that the light absorption ability and electron hole separation rate of PBF‐OCN were greatly improved compared with that of OCN, and the rate constant for photocatalytic removal MB of PBF‐OCN‐1 was about 1.39 times of that OCN. The growth of Escherichia coli (E. coli) and Staphylococcus aureus (S. aureus) could be significantly inhibited by PBF‐OCN under visible light, among which, the inhibition of PBF‐OCN‐3 was the most excellent, with the diameter of the circle of inhibition reaching 20.69 mm for E. coli, and 21.30 mm for S. aureus, and the inhibition rate against E. coli calculated by plate counting method reached 97.0%. The minimum inhibitory concentration for E. coli and S. aureus was 0.0625 mg/mL, respectively, and the possible inhibition mechanism of the samples was explored. The good synergistic antibacterial effect of PBF‐OCN is expected to be applied in water treatment, antibacterial devices, packaging materials, and other fields.