One of the main goals of Cosmology is to search for the imprint of primordial gravitational waves in the cosmic microwave background polarisation field, to probe inflationary theories. One of the obstacles toward the detection of the primordial signal is to extract the cosmic microwave background B-mode polarisation from astrophysical contaminations. Most of efforts focus on limiting Galactic foreground residuals, but extragalactic foregrounds cannot be ignored at large scale (ℓ 150), where the primordial B-modes are the brightest. We present a complete analysis of extragalactic foreground contamination due to polarised emission of radio and dusty star-forming galaxies. We update or use up-to-date models that are validated using the most recent measurements of source number counts, shot noise and cosmic infrared background power spectra. We predict the flux limit (confusion noise) for the future CMB space or balloon experiments (IDS, PIPER, SPIDER, LiteBIRD, PICO), as well as ground-based experiments (C-BASS, NEXT-BASS, QUIJOTE, AdvACTPOL, BICEP3+Keck, BICEPArray, CLASS, SO, SPT3G, S4). Telescope aperture size (and frequency) is the main characteristic impacting the level of confusion noise. Using the flux limits and assuming constant polarisation fractions for radio and dusty galaxies, we compute the B-mode power spectra of the three extragalactic foregrounds (radio source shot noise, dusty galaxy shot noise and clustering), discuss their relative levels and compare their amplitudes to that of the primordial tensor modes parametrized by the "tensor-to-scalar ratio" r. At the reionization bump (ℓ=5), contamination by extragalactic foregrounds is negligible. At the recombination peak (ℓ=80), while the contamination is much lower than the targeted sensitivity on r for large-aperture telescopes, it is at comparable level for some of the medium-(∼1.5m) and small-aperture telescope (≤0.6m) experiments. For example, the contamination is at the level of the 68% confidence level uncertainty on the primordial r for the LiteBIRD and PICO space experiments. These results have been obtained in the absence of multi-frequency component separation (i.e. looking independently at each frequency). We stress that extragalactic foreground contaminations have to be included in the input sky models of component separation methods dedicated to the recovery of the CMB primordial B-mode power spectrum. Finally we also provide some useful unit conversion factors and give some predictions for the SPICA B-BOP experiment, dedicated to Galactic and extragalactic polarisation studies. We show that SPICA B-BOP will be limited at long wavelength by extragalactic foreground contamination for long integration in polarisation, but very short integration in intensity.Lagache et al.: Impact of polarised extragalactic sources on the measurement of CMB B-mode anisotropies