Easiest is to call your carrier and request it. They should provide it for free so long as you have been a customer in good standing for 3 or more months. This only works if the BlackBerry you want to unlock was originally branded to/sold by your carrier. If it came from Vodafone for example, O2 won't have the code.
If that's not an option, go with a reputable unlocking company like Horizon Wireless
. Of course you can always spin the wheel of chance and try one of those bargain-basement unlocking services, but so many of them are just outright scams, while others are simply incompetent. Why mess with them and suffer the headaches? Horizon Wireless is a class outfit, lots of positive feedback by users here (me included!), and they guarantee either results or a refund.