Cilia and flagella exhibit regular bending waves that perform mechanical work on the surrounding fluid, to propel cellular swimmers and pump fluids inside organisms. Here, we quantify a force-velocity relationship of the beating flagellum, by exposing flagellated Chlamydomonas cells to controlled microfluidic flows. A simple theory of flagellar limit-cycle oscillations, calibrated by measurements in the absence of flow, reproduces this relationship quantitatively. We derive a link between the energy efficiency of the flagellar beat and its ability to synchronize to oscillatory flows.