Penicillin G injection is used to treat and prevent certain infections caused by bacteria. Penicillin G injection is in a class of medications called penicillins. It works by killing bacteria that cause infections. Antibiotics such as penicillin G injection will not work for colds, flu, or other viral infections.