Disable automatic iTunes launch when iPhone is plugged in via USB
iTunes

Open iTunes, select your device, go to the Summary tab and unselect either Open iTunes when this iPhone is connected, or Automatically sync when this iPhone is connected depending on your version of iTunes.

Also, you might wish to disable iTunes Helper. Go to System Preferences → Users &amp; Groups → Login Items and delete iTunes Helper from the list.
iPhoto

Open iPhoto, open Preferences (iPhoto → Preferences or ⌘,). Select General tab and set Connecting camera opens to No application.
Photos (new version of iPhoto)

Let Photos open when you connect your device, select the "Import" tab and untick the box for "Open Photos for this device"