My advice is to apply as soon as possible because you're going to need it to do a lot of things once you're there. You can do it at an Italian embassy. Have a read of more tax-related things in banking, money and taxes in Italy.
Have you decided on where to stay in Italy? Will you be working?
You will need a codice fiscale to conduct almost any personal business in Italy, including renting a home, opening a bank account, getting a phone etc. etc. Get one ASAP.