How do you use an op-amp as a switch?
In your lectures, you should have been introduced to the basic equation for an ideal op amp: Vout = G (V+ - V-). Where G is very large, like on the order of a million or so for modern op amps.
So, when V+ is one millivolt less than V-, the output will attempt to be a -1000 volts (.001 times 1,000,000), but will be at zero since that is the negative supply.
When V+ is one millivolt more than V-, the output will attempt to go to +1000 volts. Since the op amp cannot produce an output greater than its positive supply voltage, that will be what it does instead.
Note that this assumes that the op amp is what's called a rail-to-rail output amp. You should be aware that many op amps, especially older models like 741s, 356s, TL081/82/84, etc, will not be able to drive closer to the power supply lines than about 3 volts, which may affect a given circuit.