Yes, you have to pay both national and local taxes when you leave. If you don’t, you will be subject to a penalty for failure to pay, as well as interest on the unpaid amount.
For national taxes, you have to file a tax return and pay tax by March 15 of the following year of your departure. If you are not in the country such that you can’t file your taxes on your own, it is common to have a tax attorney take care of the filings on your behalf. In this case, you should inform your local tax office before your departure. If you don’t have a tax attorney or prefer to not use one, you should finish your tax returns and payments by yourself before you leave.
For local taxes, you also should appoint a tax attorney before your departure from the country. One point which you should note is that local taxation is different from national taxes in that local taxes are imposed in full on a resident who has a domicile in Japan as of January 1 for each year. Therefore, if you leave by December 31 2012, local taxes for 2013 (which is calculated based on your 2012 income) will not be imposed. If you however leave after January 1, you will owe the full amount of 2013 local taxes.
Please note the information above is provided just to give you a basic understanding, and procedures differ greatly depending on the type and amount of income you earn in Japan, as well as certain other factors. Therefore, it may be best to consult with a tax accountant for further details.