Why the iPhone doesn't automatically switch 3G off when connected to a wireless network?
Although your iPhone will use WiFi when available, that's only to save your cellular data limit being reached as quickly. Your iPhone keeps the 3G antennas active (while the internet is in use) for the following reasons;


In case you have 'flaky' WiFi; your iPhone will switch between WiFi and cellular without you noticing to keep a reliable connection working source*
In case you leave WiFi range; your iPhone can then immediately switch to cellular and use it right away without any delays.
In case your WiFi network doesn't have a 'proper' internet connection; if your WiFi network can't load certain pages (either because it's configured incorrectly, or because of a fault/security settings) your iPhone will use cellular to load those pages if possible. **


So, to answer your question, the iPhone keeps your 3G connection live while the phone is using the internet in some way so you can have a reliable connection. Your phone will only turn it off automatically when/if the phone is trying to save power.

*I believe the toggle to enable/disable this feature has been removed, but the feature still exists (and remains always on).

**I've seen this happen with those WiFi networks which would make you fill in a form/login before using the connection. The phone would be connected to WiFi, but apps would be using 3G to load new content as I was not yet logged in