You can use AppCmd.exe, which is included in IIS 7.0 and higher, in fact, the configuration editor in IIS Manager automatically generates a command line for you, for example, here it will set the test key for NewValue for / TestApp inside the Default website:
appcmd.exe set config "Default Web Site/TestApp" -section:appSettings /[key='test'].value:"NewValue"
source share