The chemical reactions and pathways involving a beta-lactam antibiotic, any member of a class of natural or semisynthetic antibiotics whose characteristic feature is a strained, four-membered beta-lactam ring. They include the penicillins and many of the cephalosporins.