As you probably know, although it can be generated in a "formally correct" way by using unofficial online tools, only Tax codes issued by the Italian Revenue Agency/ Agenzia delle Entrate are valid by law.
Agenzia Delle Entrate, who keeps the tax registry, has a database of the valid tax codes and anyone, including all citizens, public agencies, banks, and private companies can consult it.
A tool is available on their website to check its valifdity: just type your tax code in the Codice Fiscale field, solve the captcha and press the Invia button.
If the output is CODICE FISCALE VALIDO your tax code is official and valid.
If the output is CODICE FISCALE NON VALIDO (and you didn't misspell it) you need to apply for the valid one to the revenue agency