I have an iPhone 4 on which the volume setting keeps changing to its lowest value. The iOS 4.1 upgrade had no affect. The only way I seem to be able to fix this is to go to Settings > Sounds and move the Volume slider all the way to the left and then back again to my desired volume level.
Try resetting your iPhone by pressing the home and sleep buttons until you see the Apple logo, ignoring the slider. Takes about 5-15 secs of button holding and you won't lose any data or settings.