You are mistaking grammar, meaning, and usage.
Your first sentence may possibly be grammatical, but it is hard to imagine a situation that would be described by a native speaker with that sentence.
If the meaning to be conveyed is that A owned a house at the time when he met B, that meaning would be expressed as
A owned a house when he met B or, less exactly, A had a house when he met B.
If the meaning to be conveyed is that A did not own a house when he met B despite having previously owned one, your sentence might be grammatical, but a native speaker of US English would use something like
A did not own a house when he met B although he had owned one years before.
The point is that when is used in such constructions to link contemporaneous situations. Using tense to modify the normal meaning of when may not violate any rule of grammar, but is far from idiomatic in the US.