No, it should definitely not be in code. This means if you use source control it will be commited to the repository where anyone with access can see it. If it is in a config then you can ignore the config file.
You also normally want to have test environment keys vs production keys. With a config it's possible that none of the developers working on the code actually know the production key. The less people that know a secret the better.
There are also additional measures you can take to encrypt the config file. For example with .NET's app.config you can encrypt the config at a machine or user level using DPAPI.