Detect when signal starts oscillating
As far as I can tell from the graph, the variance of the signal goes up substantially under "oscillation" conditions. So, monitor the variance over a rolling window. High variance indicates oscillation. To choose the window width, consider:


if the window is too short, the computed variance will be too noisy
if the window is too long, the monitor will be slow to respond


Also note that, given the information you've provided, there is no way to tell the difference between the step function signal itself and the beginning of an oscillation condition. You should therefore impose some auxiliary condition on the signal to avoid false positive detection. For a square wave signal, I'd suggest detecting extremely large time derivative. If the derivative exceeds some critical value, you probably have a square wave step, not an oscillation. So the criterion is:

oscillation if variance exceeds $V_{min}$ and max derivative is smaller than $D_{max}$.