Both terminals have 'Day and Shower' rooms where you can take a shower for 500 Yen for 30 minutes, or get a day room for 1000 Yen per hour. The shower rooms are tiny, but fully equipped. Bring your own razor and toothbrush. For more information, see the "Day and Shower Room" section of the Narita Airport Web page.
In addition, many of the airline lounges also have shower rooms.