We use WIX to change the application’s configuration file. It works really well, you’ll need to add wixUtilExtension.dll in the reference.
WIX sample:
<Component Id="ChangeConfig" Guid="[YOUR_GUID_HERE]">
<File Id="App.config" Name="MyApplication.exe.config" Vital="yes" KeyPath="yes" Source="[Path to project dir]\app.config" />
<util:XmlFile Id="AppConfigSetConnStr" Action="setValue" Permanent="yes" File="[#App.config]"
ElementPath="/configuration/connectionStrings/add[\[]@name="MyDatabaseName"[\]]" Name="connectionString"
Value="Your Connection string values here" />
</Component>
It actually depends on what you are using to create the installer, What are you using ?
Have alook at the WIX Tutorial.