Band bending is a central concept in solid-state physics that arises from local variations in charge distribution especially near semiconductor interfaces and surfaces. Its precision measurement is vital in a variety of contexts from the optimisation of field effect transistors to the engineering of qubit devices with enhanced stability and coherence. Existing methods are surface sensitive and are unable to probe band bending at depth from surface or bulk charges related to crystal defects. Here we propose an in-situ method for probing band bending in a semiconductor device by imaging an array of atomic-sized quantum sensing defects to report on the local electric field. We implement the concept using the nitrogen-vacancy centre in diamond, and map the electric field at different depths under various surface terminations. We then fabricate a two-terminal device based on the conductive two-dimensional hole gas formed at a hydrogen-terminated diamond surface, and observe an unexpected spatial modulation of the electric field attributed to a complex interplay between charge injection and photo-ionisation effects. Our method opens the way to three-dimensional mapping of band bending in diamond and other semiconductors hosting suitable quantum sensors, combined with simultaneous imaging of charge transport in complex operating devices.