When Sm is changed to off, current trough L1 still wants to flow, but there is not path. As a result L1 voltage will be increased. Because output voltage is constant (regulator) , voltage at the emitter of Sm is going down until it is limited by something. In this case for emiter voltage of -Vd diode d12 is on.
When Sa or Sm conducts, there are a path and L1 starts charging. but when Sa or Sm stop conducting, there are no path but L1 opposes to changes in the flux of current so it needs a path for it. D12 is to provide a path for L1 when Sa and Sm doesn't work.