When would you use a digital potentiometer over PWM and a mosfet/transistor? I don't understand the advantages/disadvantages between the two.
Digital potentiometers are (in their output stage) linear devices used to set a voltage division / resistance ratio through a switched set of resistive elements. They are generally low current, normally very linear, relatively low noise (although not as low as a high specification real potentiometer) and useful for signal-level processing.
PWM with a (presumably open-drain) FET output allows for high speed variable duty-cycle switching of a much larger load (up to low kW is quite possible with FETs - and beyond that with IGBT combinations). Since the switching device is either hard on (small voltage drop) or hard off (very low leakage current) the dissipated power (current x voltage) is very low, making it an efficient way to vary the power applied to a device. PWM is, however, relatively noisy, producing spectral artefacts at multiples of the switching frequency, along with modulated artefacts from any varying of the duty cycle.
Depending on what you are trying to achieve, both have their place. Want to dim a 20W LED module? That'll be a PWM controlled open-drain FET with a constant current power source. Want to adjust the offset going in to an opamp input? That would be best done with a digital potentiometer.