Penicillin is used to treat infections caused by bacteria. They work by killing the bacteria or preventing their growth.