Context. There is now a large consensus that the current epoch of the cosmic star formation history (CSFH) is dominated by low mass galaxies while the most active phase, between redshifts 1 and 2, is dominated by more massive galaxies, which evolve more quickly. Aims. Massive galaxies tend to inhabit very massive haloes, such as galaxy groups and clusters. We aim to understand whether the observed "galaxy downsizing" could be interpreted as a "halo downsizing", whereas the most massive haloes, and their galaxy populations, evolve more rapidly than the haloes with lower mass. Methods. We studied the contribution to the CSFH of galaxies inhabiting group-sized haloes. This is done through the study of the evolution of the infra-red (IR) luminosity function of group galaxies from redshift 0 to redshift ∼1.6. We used a sample of 39 X-rayselected groups in the Extended Chandra Deep Field South (ECDFS), the Chandra Deep Field North (CDFN), and the COSMOS field, where the deepest available mid-and far-IR surveys have been conducted with Spitzer MIPS and with the Photodetector Array Camera and Spectrometer (PACS) on board the Herschel satellite. Results. Groups at low redshift lack the brightest, rarest, and most star forming IR-emitting galaxies observed in the field. Their IR-emitting galaxies contribute ≤10% of the comoving volume density of the whole IR galaxy population in the local Universe. At redshift 1, the most IR-luminous galaxies (LIRGs and ULIRGs) are mainly located in groups, and this is consistent with a reversal of the star formation rate (SFR) vs. density anti-correlation observed in the nearby Universe. At these redshifts, group galaxies contribute 60-80% of the CSFH, i.e. much more than at lower redshifts. Below z ∼ 1, the comoving number and SFR densities of IR-emitting galaxies in groups decline significantly faster than those of all IR-emitting galaxies. Conclusions. Our results are consistent with a "halo downsizing" scenario and highlight the significant role of "environment" quenching in shaping the CSFH.