Is there an iPhone app to control the volume depending on traveling speed or surrounding sounds?

I do not know of such an app. I have looked extensively, but have not found any that does this specifically.

Apple has a patent for a technology that would, among other things, build in this sort of feature. Think of it as an extension of the proximity sensor on the front of the phone that turns the screen off when your ear is against the receiver. If implemented, the phone would gain much more situational awareness. I say 'if' because I'd expect to hear something about this during a product announcement.

The full text of the patent (#8384684) is available here. EDIT: this is a related patent, but not the one I intended to attach. I'll correct shortly.