It's in the EXIF data.
Most cataloging programs like Lightroom, Aperture, ACDSEE etc can apply this info. I have this applied on import, and you can also set it in the camera in some cases.
If you then want to take that info and apply it onto the image so it appears visibly, then again you can use the same tools (but in different ways)
Lightroom (I'll reference this as I use it) can apply what it calls a copyright watermark on export. Essentially it puts your name on the lower edge of the image.
Lightroom has a plugin available (for free) called Mogrify. This allows you to stamp data from the EXIF as text, so filename, copyright info etc.
We discussed it in this thread a while ago
http://www.talkphotography.co.uk/forums/showthread.php?t=207815