Harry Maguire has headed Manchester United into the fourth round of the FA Cup with a late goal against his former club Leicester City.