Some microorganisms, such as spermatozoa, synchronize their flagella when swimming in close proximity. Using a simplified model (two infinite, parallel, two-dimensional waving sheets), we show that phase locking arises from hydrodynamics forces alone, and has its origin in the front-back asymmetry of the geometry of their flagellar waveform. The time evolution of the phase difference between coswimming cells depends only on the nature of this geometrical asymmetry, and microorganisms can phase lock into conformations which minimize or maximize energy dissipation.