How do I keep just my iCloud contacts?
With Mavericks (OSX 10.9) once iCloud syncing activated you will not have the top level "On My Mac" anymore.

On earlier version best would be to :


Select every contact "On My Mac" (cmd - A) and drag and drop them
to your "~/Desktop". This will create one VCF. To keep you group
organisation you may want to proceed on a per group basis.
Delete the selection of contacts.
Delete the group(s).
Make sure in Contacts Preferences the default account is "iCloud". If you are
missing contacts on iCloud simply drag and drop back the VCF file to
"All iCloud" or whatever group, you will be prompted to review
duplicates.