Even it was probably not intended, Irene saved Sherlock’s life… So Sherlock did the same for her, even though she works with Moriarty.
As simple as that. They are meant for each other, in a way.
While I can appreciate the basic idea linking these two sequences (Character A saves Character B’s life at the beginning of a story, Character B saves Character A’s life at the end of it), the idea of returning a favor implies that you know someone did something good for you in the first place.
Nowhere in BELG is it stated or shown on screen either by Sherlock or anyone else that Sherlock knows that Moriarty was on the phone with Irene at the end of the pool scene. Yes, Irene says in front of Sherlock that she had help from Jim, but she never specifies whether Jim contacted her first or vice versa, never specifies a time frame, nor the method of contact.
Sherlock may have wanted to help Irene because he cared about her for whatever reason, but not because he wanted to pay her back for saving his life in the beginning (because we’re never shown or told that he knew about it in the first place).