Oxacillin injection is used to treat infections caused by certain bacteria. Oxacillin injection is in a class of medications called penicillins. It works by killing bacteria. Antibiotics such as oxacillin injection will not work for colds, flu, or other viral infections.