Yes. It is illegal to have two PANs and the penalty for such an offence is Rs.10,000/-. You need to surrender to anyone PAN to your assessing officer in the following manner:
You can also surrender the PAN online by filing an application “change in PAN data” through UTI PAN centres or NSDL TIN Facilitation centres. In the application fill the spare PAN number in the last row of the form.
a. Write a letter to the assessing officer under whose jurisdiction you have been filing your returns. (to know your AO, use this link: https://incometaxindiaefiling.gov.in/e-Filing/Services/KnowYourJurisdictionLink.html ). The letter must contain details such as your name, contact details, details of the PAN card to be retained, details of the duplicate PAN card(s) which you need to surrender, etc.
Keep the acknowledgement copy of the letter that you have filed with the I-T department stating that you are surrendering your additional PAN. That is sufficient as proof of surrender and no additional confirmation from the I-T authorities is required. On receipt of the acknowledgement, there is no need for you to wait for the intimation from the Income-tax department considering that the PAN submitted has now been cancelled by them. The acknowledgement copy of the letter submitted will more than solve the purpose.
b. Manually fill the Form No. 49A for change/correction in PAN and submit the same at your nearest UTI PAN centre or NSDL TIN Facilitation centre.