Use pbcopy:
pbcopy
echo foo | pbcopy
Also see man pbcopy for info on it and pbpaste.
man pbcopy
pbpaste