The original question:
Who was the girl you were talking to?
How can I report it?
1. He asked who was the girl I was talking to.
2. He asked who the girl was I was talking to.
3. He asked me who I had been talking to.
Do I need to backshift the tense?
He asked who was the girl I had been talking to.