We study the relation of AGN accretion, star formation rate (SFR), and stellar mass (M$_*$) using a sample of $approx$ 8600 star-forming galaxies up to z=2.5 selected with textit{Herschel} imaging in the GOODS and COSMOS fields. For each of them we derive SFR and M$_*$, both corrected, when necessary, for emission from an active galactic nucleus (AGN), through the decomposition of their spectral energy distributions (SEDs). About 10 per cent of the sample are detected individually in textit{Chandra} observations of the fields. For the rest of the sample we stack the X-ray maps to get average X-ray properties. After subtracting the X-ray luminosity expected from star formation and correcting for nuclear obscuration, we derive the average AGN accretion rate for both detected sources and stacks, as a function of M$_{*}$, SFR and redshift. The average accretion rate correlates with SFR and with M$_*$. The dependence on SFR becomes progressively more significant at z$>$0.8. This may suggest that SFR is the original driver of these correlations. We find that average AGN accretion and star formation increase in a similar fashion with offset from the star-forming main-sequence. Our interpretation is that accretion onto the central black hole and star formation broadly trace each other, irrespective of whether the galaxy is evolving steadily on the main-sequence or bursting.