We investigate which practical constraints are imposed by foregrounds to the detection of the B-mode polarization generated by gravitational waves in the case of experiments of the type currently being planned. Because the B-mode signal is probably dominated by foregrounds at all frequencies, the detection of the cosmological component depends drastically on our ability for removing foregrounds. We provide an analytical expression to estimate the level of the residual polarization for Galactic foregrounds, according to the method employed for their subtraction. We interpret this result in terms of the lower limit of the tensor-to-scalar ratio r that allows to disentangle the cosmological B-mode polarization from the foregrounds contribution...