How do I connect a switch and receptacle in the same box?
In this image the top outlet is controlled by the switch, while the bottom is always hot


Using a crimp cap (or other approved means), connect two bits of bare or green wire to the incoming bare/green wire. If this is a metal box, use three bits of wire, and attach one to the box using an approved grounding screw.
Attach one bare/green wire to each device.
Connect the incoming white (grounded "neutral") wire to one of the silver colored screws on the receptacle.
Break the tab on the side of the receptacle, between the brass colored screws.
Using a twist-on wire connector (or other approved method), connect two bits of black wire to the incoming black (ungrounded "hot") wire.
Connect one black wire from the bundle to the switch.
Connect the other black wire from the bundle to one of the brass colored screws on the receptacle.
Connect a bit of wire from the remaining screw on the switch, to the remaining brass screw on the receptacle.