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, as and may
Neither, nor, so, as and may 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 in exclamations
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.