You have three ways to choose one from:
1. You can use the services of www.nokialockcode.com to generate a master code for your Nokia device using its IMEI number and key that in the place of the security code to reset the currently forgotten one.
2. You can either update or reflash in your Nokia device's software/firmware using Nokia PC Suite and/or JAF / Phoenix
3. Lastly, you have the option of taking your Nokia device to your nearest Nokia care centre together with proof that you own/purchased the device and they will have the security code master reset for you.