[1] Only when I heard him speak I recognised him.
[2] Only when I heard him speak did I recognise him.
[2] has subject-auxiliary inversion, and is the correct version.
[2] is correct if the sentence means the same thing as "I recognized him only when I heard him speak."
I didn't recognize him just by looking at him. But then he spoke. Only when I heard him speak did I recognize him.
[1] is correct if "only" is a coordinating conjunction conjoining the independent clause "when I heard him speak, I recognized him" to whatever came before.
I had assumed that I didn't know him at all. Only, when I heard him speak, I recognized him.
The answer thus depends on how you interpret "only," semantically and syntactically.
You're repeating yourself. You made the point about the possibility of "only" being a coordinator in #3.
It's true that "only" behaves like a coordinator in certain constructions, where it typically has a meaning similar to "but":
I would have gone only/
but I was too busy.
But it differs from coordinators in a few ways; for example it cannot appear in multiple coordinations: we can hardly say
? I would have gone [
only I was too busy]
, [
only I was not really interested]
.
And, unlike coordinators, it can only be followed by a finite clause.
For these (and other) reasons, it would be unwise to treat "only" as a member of the coordinator category. I would, however, go along with a claim that it is a preposition, one that takes a clausal complement.
In any case, and most importantly, the far more salient interpretation of the OP's example is that "only" is not a coordinator but an adverb, a focusing modifier. This is reinforced by the answer key in the OP's book, which was looking for the inverted "did I". If the authors intended "only" to be analysed as a coordinator, one would expect them to have provided some prior discourse setting the appropriate context.
This inversion occurs in declarative clauses only when certain types of element are put in front position. Negatives are one very obvious type of element that trigger subject-auxiliary inversion when fronted:
Never had I seen such chaos.
At no stage were they in danger.
"Only" is not negative, but it is semantically close to a negative in that Only John liked it, for example, entails No one other than John liked it..
Note that the inversion is also found with some items that are not similar to negatives:
John enjoyed it and so did Robert.
This fleshes out the interpretation on which "only" modifies the "when"-clause.
It says nothing about the other interpretation, which is equally possible.
You're repeating yourself yet again.
The purpose of those examples was to usefully show the range of expressions that can trigger subject-auxiliary inversion.