I also switch off the camera before swapping lenses. Been doing this for years. Can’t remember where I learned to do this.
I just Googled it and the general consensus is that the sensor is ‘charged’ when camera is on and thus can attract dust - as in static electricity etc.
The other opinion was that as you twist the lens to remove you may risk electrical contacts shorting. I doubt this theory.