This document is one of a series of whitepapers from the USQCD collaboration. Here, we discuss opportunities for lattice QCD in quark and lepton flavor physics. New data generated at Belle II, LHCb, BES III, NA62, KOTO, and Fermilab E989, combined with precise calculations of the relevant hadronic physics, may reveal what lies beyond the Standard Model. We outline a path toward improvements of the precision of existing lattice-QCD calculations and discuss groundbreaking new methods that allow lattice QCD to access new observables.