I quoted much contents from some posted spreaded in the coner of internet, but did organize them a little. You can find all references inside the body :-)
The Microsoft philosophy regarding default audio playback/record is that it should not be changed progmatically by user applications.
Technically the correct method of setting the default audio device in OS >= Win98 would be using the SetupAPI Functions when the audio device is installed using the SetupPreferredAudioDevices keyword in the driver INF file. This is the only fully documented method I am aware of.
Microsoft Vista has an undocumented function in mmdeviceapi.dll exported as SetDefaultAudioEndpoint which could be used to set the default audio device. But once again it is not intended for use.
Fortunately I found an open-source project on Google Code, Rainmeter, which contains source code example of how to get routines from mmdeviceapi.dll and achieve the goal of setting default audio device. It's a sub-project in folder Plugins/PluginWin7Audio.
Rainmeter Homepage: http://code.google.com/p/rainmeter