Avian migration, which involves billions of birds flying vast distances, is known to influence all aspects of avian life. Here we investigate how birds fit moult into an annual cycle determined by the need to migrate. Large variation exists in moulting patterns in relation to migration: for instance, moult can occur after breeding in the summer or after arrival in the wintering quarters. Here we use an optimal annual routine model to investigate why this variation exists. The modelled bird's decisions depend on the time of year, its energy reserves, breeding status, experience, flight feather quality and location. Our results suggest that the temporal and spatial variations in food are an important influence on a migratory bird's annual cycle. Summer moult occurs when food has a high peak on the breeding site in the summer, but it is less seasonal elsewhere. Winter moult occurs if there is a short period of high food availability in summer and a strong winter peak at different locations (i.e. the food is very seasonal but in opposite phase on these areas). This finding might explain why only long-distance migrants have a winter moult.