The chemical reactions and pathways involving sphingomyelin, N-acyl-4-sphingenyl-1-O-phosphorylcholine, any of a class of phospholipids in which the amino group of sphingosine is in amide linkage with one of several fatty acids, while the terminal hydroxyl group of sphingosine is esterified to phosphorylcholine.