  Negatively charged boron vacancies ($\small{V_B^-}$) in hexagonal boron
nitride (hBN) have recently gained interest as spin defects for quantum
information processing and quantum sensing by a layered material. However, the
boron vacancy can exist in a number of charge states in the hBN lattice, but
only the -1 state has spin-dependent photoluminescence and acts as a
spin-photon interface. Here, we investigate charge state switching of
$\small{V_B}$ defects under laser and electron beam excitation. We demonstrate
deterministic, reversible switching between the -1 and 0 states ($\small{V_B^-
\rightleftharpoons V_B^0 + e^-}$), occurring at rates controlled by excess
electrons or holes injected into hBN by a layered heterostructure device. Our
work provides a means to monitor and manipulate the $\small{V_B}$ charge state,
and to stabilize the -1 state which is a prerequisite for optical spin
manipulation and readout of the defect.
