Jblb Is it ok ? About your sketch, by default Wire use I2C1 with PB7 (SDA) / PB6 (SCL). So seems you want to use also I2C1 on PB9/PB8 which is fine using setSCL/SDA. For the Wire2 as you already instantiate it with the proper pins, you don't need to re-set the pins using: Wire2.setSCL(PB_10); Wire2...
Hnestly, I don't know why this not work.
Maybe an issue with the reenumeration.
You can try to change the USBD_ENUM_DELAY value which is set to 10 ms by default.