  The optical properties of monolayer and bilayer transition metal
dichalcogenide semiconductors are governed by excitons in different spin and
valley configurations, providing versatile aspects for van der Waals
heterostructures and devices. We present experimental and theoretical studies
of exciton energy splittings in external magnetic field in neutral and charged
WSe$_2$ monolayer and bilayer crystals embedded in a field effect device for
active doping control. We develop theoretical methods to calculate the exciton
$g$-factors from first principles and tight-binding for all possible
spin-valley configurations of excitons in monolayer and bilayer WSe$_2$
including valley-indirect exciton configurations. Our theoretical and
experimental findings shed light on some of the characteristic
photoluminescence peaks observed for monolayer and bilayer WSe$_2$. In more
general terms, the theoretical aspects of our work provide new guidelines for
the characterization of single and few-layer transition metal dichalcogenides,
as well as their heterostructures, in the presence of external magnetic fields.
