That depends on if the switch is designed for it. The motor won't have problem but as Brent pointed out, the rest of the machine may not like it because the speed change can be pretty harsh. My 15" Enterprise has a 3 position rotary mechanical switch (off - low - high) - it does not look like it is designed for load breaking an inductive load (there is quite an arc flash that proper contactors can manage). I have never used it for "on the fly" speed changes - besides it is an awkward location, way down at the end. My understanding is that this type of switch is not designed for changes on the fly. If it is sort of a mechanical rotary arrangement about 2" in diameter that goes click/click/click - I'd suggest not doing it on a routine basis.
If I want to switch on the fly (sort of ), I tap the foot brake (which trips the motor's contactor), click the switch and hit the start button again - it works fine, but awkward. I've owned the lathe for 38 years, I've used it a lot - the lack of on the fly speed change is not a big deal.
I also have a smaller lathe (11" Smart and Brown - it has a fairly large 3 phase motor - large because it wound for 3 speeds - 2 poles, 4 poles or 6 poles), which is set up with contactors for selecting the speeds. That machine is designed for speed change on the fly, the switches are conveniently located - it is a nice feature. It is nice for threading long pieces because I can speed shift while threading, then come slow right up to a shoulder! The fwd - rev - stop are all separate buttons (again by contactors - the one motor has 5 contactors controlling it). The speed up works great, the speed down tends to throw off one of the drive belts - so to slow down I first press the stop button and let the machine coast for a few seconds, select the lower speed contactor and press the start button. The machine originally had an electro-mechanical brake - but it was gutted by the previous owner (NAIT), so the machine has about a 10 second coast down (depending on how fast and what is mounted on the spindle).
The S&B is a nifty little machine, the power is delivered from the motor to an intermediate 2 spd gear box (which is also shift on the fly) by a 2" belt, then up to the spindle with another 2" belt - it is the lower belt that flips off on sudden speed changes. Although it uses wide flat belts for the drive, one never does any belt shifting (apparently "the flat belt provides smoother delivery of power and there is less tendency for gear patterning to effect the finish imparted on the piece being machined" - as if I'd ever be able to tell). Back in the day, this was not a cheap machine, very well thought out. Of course now one would use a frequency drive. This machine, with the considerable gearing employed, retains good torque when operating at the low speed ranges (still some drop off, as the low speed setting is about 1/2 the power of the highest speed setting).
I digress - you asked if you could switch on the fly (low speed to high speed). The answer is - that depends on the switch. Do you have a manual?