We analyze a Neutron Star Interior Composition Explorer (NICER) observation of the black hole X-ray binary MAXI J1820+070 during a transition from type-C to type-B quasi-periodic oscillations (QPOs). We find that below ∼2 keV, for the type-B QPOs the rms amplitude is lower and the magnitude of the phase lags is larger than for the type-C QPOs. Above that energy, the rms and phase-lag spectra of the type-B and type-C QPOs are consistent with being the same. We perform a joint fit of the time-averaged spectra of the source, and the rms and phase-lag spectra of the QPOs with the time-dependent Comptonization model vkompth to study the geometry of the corona during the transition. We find that the data can be well-fitted with a model consisting of a small and a large corona that are physically connected. The sizes of the small and large coronae increase gradually during the type-C QPO phase whereas they decrease abruptly at the transition to type-B QPO. At the same time, the inner radius of the disc moves inward at the QPO transition. Combined with simultaneous radio observations showing that discrete jet ejections happen around the time of the QPO transition, we propose that a corona that expands horizontally during the type-C QPO phase, from ∼104 km (∼800 Rg) to 105 km (∼8000 Rg) overlying the accretion disc, transforms into a vertical jet-like corona extending over ∼104 km (∼800 Rg) during the type-B QPO phase.