Public transport at night in Tokyo is notoriously bad, but using Keisei to travel from Haneda to Narita train service gives you a bit more leeway: the first train leaves HND at 05:34 with a transfer in Shinagawa, arriving at 07:37. No luck in the other direction though.
Alternatively, why not take a late train to central Tokyo, spend the night somewhere central, and then continue to Narita in the morning?