This is called 'inversion'. It means inverted normal word-order (as we do in questions) and it is quite formal. We use inversion after negative or restrictive expressions (never, not only, only, little, no sooner....) at the beginning of the clause. Sometimes, as in the conditional examples above, we use it for emphasis or to make it even more unlikely.
Not only IS SHE beautiful, but she also sings beautifully.
Little DID SHE know what was in store for her
Hardly HAD SHE entered the room when she heard someone screaming in the street.
SHOULD I be mistaken, please let me know.