Myriads of cilia beat on ciliated epithelia, which are ubiquitous in life. When ciliary beats are synchronized, metachronal waves emerge, whose direction of propagation depends on the living system in an unexplained way. We show on a reconstructed human bronchial epithelium in vitro that the direction of propagation is determined by the ability of mucus to be transported at the epithelial surface. Numerical simulations show that longitudinal waves maximize the transport of mucus while transverse waves, observed when the mucus is rigid and still, minimize the energy dissipated by the cilia.