A good place to hide the nail holes on your molding or door trim is to put them in the groove (assuming your door trim has grooves) if not you should nail through the thickest part of the door angling the nails to hit the stud if you can.
If you are going to paint your trim then use putty to fill the hole, if you are staining your door a good method is to use some sawdust from the trim mixed with wood glue to fill the holes as that makes the most invisible holes.