The chemical reactions and pathways involving any betaine, the N-trimethyl derivative of an amino acid.