The extreme conditions of density and temperature make the Universe around the initial moment of the Big-Bang, an extraordinary laboratory for probing poorly understood physics, mixing quantum and general relativity phenomena. The physics of the early Universe can be studied through the Cosmic Microwave Background (CMB), the oldest observable "light'" in the Universe. The CMB temperature has been mapped recently with unprecedented precision by the Planck satellite. However, its full potential in testing fundamental physics lies in measurements of its polarization at high resolution and sensitivity. This will be unlocked for the first time with current and future ground-based and space-based observatories. The main goal is to discover the imprint of inflation, when the Universe expanded by an incredibly large factor during a fraction of a second around the time of the Big Bang. Inflation models predict the production of stochastic gravitational waves which distorted spacetime while propagating through the Universe, and generated an observable parity-violating signature in the polarization of the CMB, the so-called B-mode polarization. This nano-Kelvin signal is quantified by the tensor-to-scalar ratio parameter r. Current limits are given by the BICEP/Keck ground experiments, and the goal of the community is to achieve an accuracy at the level of 10-3 within a few years. The potential of primordial B-modes to help identify what prompted inflation, whilst also investigating physics at grand unification energy scales, makes the search for this faint CMB polarization signal one of the most compelling goals of modern cosmology. However, with the capabilities of next-generation experiments, the large leap in detector count and experiment complexity introduce challenges to current methods. Some of these challenges are intrinsically computational: to explore the enormous datasets, we must develop sufficiently reliable and efficient data analysis pipelines to extract features from the observations. Other challenges are algorithmic, including the selection of optimal ways to disentangle the CMB signal of interest from foregrounds and to mitigate systematic errors. This in turn imposes stringent requirements on the instrument design and calibration. Tackling these challenges is the focus of my research. This thesis presents several methods for foreground cleaning and mitigation of instrument systematics, that allow for unbiased measurements of the CMB B-mode polarisation power spectrum, that can be used for cosmological parameter estimation. These methods have been devised for the Simons Observatory (SO) and LiteBIRD satellite and are adaptable to a variety of CMB experiments. I present two new methods for component separation in the presence of spatial variations in Galactic foreground spectral properties and their impact on parameter inference: a moment expansion method and a hybrid method, which is an extension of the former. Both these methods account for spatial variability while recovering unbiased constraints on r in the presence of complex foregrounds and noise. Through the development of these methods, I also contributed significantly to the SO cross-spectrum analysis pipeline, which became SO's main Small Aperture Telescope forecast likelihood pipeline. This work led to the discovery that the moments-based method is currently the most promising avenue for SO. I also present a study on the precision of angular position measurement of the half-wave plate (HWP) polarisation modulation unit for LiteBIRD, for which I developed a simulation pipeline to mitigate the propagation of HWP systematic effects to final constraints. This study is part of an instrument systematic mitigation campaign that is crucial for the success of the next-generation CMB experiments.