If you set up groups before transferring contacts to the iPhone, you can then show only a certain group (or all groups) when browsing contacts. I set up several groups in Address Book, but noticed that you can’t change which group a contact is in on the iPhone itself. Nor can you add new groups on the phone, either.
However, if you want to add a new contact to a group that is already on the iPhone, first go to the Phone Application, then tap “Contacts” and then tap the “Groups” button at the top left of the screen to select the group to which you want to add the new contact. It will return you to the Contacts screen with the group name at the top. Now tap the “+” button to add a new contact that will be associated with that group.
If I get a call or email from someone not in my contact list that I know I want in a particular group (like “Work” contacts), I go through the above steps to create the new contact in that group, then go back to the phone call or email and tap on “Add to Existing Contact” to make the new contact. If I “Create New Contact” from a recent call or an email there’s no way to edit the group into which the new contact is placed.