Subject-verb inversion is a feature of questions, but it also occurs in statements after certain phrases.
Inversion after negative adverbial expressions
Some negative adverbial expressions can be put at the beginning of a sentence for emphasis. These structures are usually found in formal, written contexts.
Inversion of the subject and auxiliary is needed after these expressions when they start a sentence.
Not only + auxiliary + subject (+ main verb)
Other expressions that can be used in this way are never, rarely, seldom, hardly when, scarcely when, no sooner than, and a number of expressions including no. Only can also be used in this way.
Inversion after neither, nor, so and as
Neither, nor, so and as can be used to say that two things are the same. Inversion of the subject and auxiliary is needed after these phrases when they are used in this way.
Inversion after had in conditional sentences
In formal, written English, inversion can be used to replace if in third-conditional sentences.
Inversion after expressions of place
After expressions of place, inversion of the subject and the verb, not an auxiliary, is possible when the expression starts the sentence.