The first time was in Sherlock's mind palace where Moriarty was taunting him and encouraging him to die. But then he mentioned that John would be in danger, which led to Sherlock fighting back and pulling through.
The second time was with his appearance at the end, just as Sherlock was about to be dispatched on what was, according to Mycroft, essentially a six month death mission.
So yes, ironically, Moriarty saved Sherlock's life twice. Just an observation I found rather amusing!
---------------------------------------------------------------------------------------------------------------------------------------------
Eventually everyone will support Johnlock.Independent OSAJ Affiliate