Duplicate contacts exist on the iPhone because it was told to sync with multiple sources of data. This is not a bug.
Most people only want a single repository of contacts so everything is nice, neat and orderly. In order to achieve this, the trend is to store everything in "the cloud" and make use of data synchronization services such as MobileMe, Google Sync etc. So the cloud database has to be the most current, up-to-date version of your contacts database.
Back up your iPhone and restore it to its original state. This will clear all information from it.
First, you might want to make sure that your Address Book (Outlook for Windows users, or whatever you chose to store your contacts) is the most updated version.
If you are a MobileMe user, first go to System Preferences>MobileMe (Control Panel>MobileMe for Windows users), choose the Sync tab, then ensure that contacts, calendars etc are selected.
Now connect your iPhone to iTunes, and choose the iPhone device within iTunes. Make sure that "Sync contacts" is NOT selected in iTunes. There will be a message to the effect that "MobileMe will now synchronize contacts over the air". This is what you want. Under the "Advanced" button, make sure that the option for "wiping the iPhone the next time it is synced" option is checked. Did I mention you will lose data on the iPhone if your MobileMe contacts database is not the latest?
When you're ready, hit the Sync button and everything will now be synced against your MobileMe database. Assuming that you have followed the steps correctly, you will no longer have any duplicate contacts, and any edits and updates performed on the iPhone, on your Mac/PC or even on a web browser with MobileMe contacts database, will all be in sync.