(A)He asked me what the matter with me was. (indirect narration)

That works but a little better might be:
(B)He asked me what was the matter with me. (indirect narration)

Word order is pretty important in English but not so important that we can't mess with it a little. To me, (B) sounds a little better than (A).