You can use Web Config Transformations to achieve this.
This will allow you to specify transform sections in your web.config and have seperate files for different environments that replace the transform tokens during build.
More info here: http://msdn.microsoft.com/en-us/library/dd465318%28v=vs.100%29.aspx
When you deploy a Web site, you often want some settings in the deployed application's Web.config file to be different from the development Web.config file. For example, you might want to disable debug options and change connection strings so that they point to different databases. This topic explains how to set up a Web.config transform file that is applied automatically during deployment in order to make changes to the deployed versions of Web.config files.
Web.config transforms are part of a broader group of settings that you can configure to automate the deployment process. For information about the tasks that are involved in setting up automated deployment, see the following topics: