Star-forming galaxies which are too faint to be detected individually produce intensity fluctuations in the cosmic background light. This contribution needs to be taken into account as a foreground when using the primordial signal to constrain cosmological parameters. The extragalactic fluctuations are also interesting in their own right as they depend on the star formation history of the Universe and the way in which this connects with the formation of cosmic structure. We present a new framework which allows us to predict the occupation of dark matter haloes by star-forming galaxies and uses this information, in conjunction with an N-body simulation of structure formation, to predict the power spectrum of intensity fluctuations in the infrared background. We compute the emission from galaxies at far-infrared, millimetre and radio wavelengths. Our method gives accurate predictions for the clustering of galaxies for both the one-halo and two-halo terms. We illustrate our new framework using a previously published model which reproduces the number counts and redshift distribution of galaxies selected by their emission at m. Without adjusting any of the model parameters, the predictions show encouraging agreement at high frequencies and on small angular scales with recent estimates of the extragalactic fluctuations in the background made from early data analysed by the Planck Collaboration. There are, however, substantial discrepancies between the model predictions and observations on large angular scales and at low frequencies, which illustrates the usefulness of the intensity fluctuations as a constraint on galaxy formation models.