Wiring a light switch and outlet on the same circuit is something that electricians do regularly. They often run wires from the switch to a remote outlet, but there's no reason why the switch and outlet can't be in the same electrical box. Of course, you need a double-gang box to accommodate both of the devices, but that's about the only complication. You might have to cut some drywall to remove the existing single-gang box and install a double-gang outlet box.
Video of the Day
If you want the switch to control the outlet, you can buy a switch-outlet combo that fits a single-gang box. These units feature only a single outlet. If you need a duplex outlet, you have to buy the switch and outlet separately and install them in a double-gang box.
Remember: Safety First
As is true when doing any electric wiring, it's important to turn off the breaker controlling the circuit before you do any electric wiring. It's always a good idea to check the wires with a voltage tester to make sure they're dead before you touch anything.
Installing a Combination Switch Outlet
You can wire a switch/outlet combo in one of three ways. In the first case, the switch controls the outlet and nothing else. To make this happen, connect the black circuit wire to the brass screw on the device, the white wire to the chrome screw and the ground wire to the green ground screw. Note that the two black terminal screws on the opposite side of the device are unused.
In the second case, you want the switch to control a light, while the outlet always has power. Before you make connections, splice the white neutral wires together with a third short length of white wire and cap the wires. This is called a pigtail. Connect the hot circuit wire to one of the black common terminals, the hot load wire to the brass terminal and the pigtailed white wire to the chrome terminal. Connect the ground wires to the ground terminal.
In the third case, the switch controls both the outlet and the light. Splice the white wires and make a pigtail, connect the pigtail to the chrome screw and then reverse the hot wires. The hot circuit wire goes on the brass screw, and the hot wire to the load goes on one of the black common terminals. Connect the ground wires to the green ground screw.
Connecting Separate Devices in a Double-Gang Box
The same three options exist when wiring separate devices. To have the switch control just the outlet, connect the hot circuit wire to one of the switch terminals, and then connect the other switch terminal to the brass terminal on the outlet with a short jumper wire. Connect the white circuit wire to the chrome terminal on the outlet. Use a bare jumper wire to connect the ground screws, and connect the circuit ground to one of the ground screws.
To have the switch control the light while the outlet always has power, connect the hot circuit wire to the brass terminal on the outlet, and then connect that terminal to one of the switch terminals with a jumper wire. The hot load wire goes on the other switch terminal. Twist the white wires together, make a pigtail and connect it to the chrome screw on the outlet. Twist the ground wires together, connect them to the ground screw on one of the devices and jump the ground screws on the devices together.
If you want the switch to control both the light and outlet, connect the hot circuit wire to one of the switch terminals, jump the other switch terminal to the brass screw on the outlet and connect the hot load wire to that terminal as well. Pigtail the white wires and connect them to the chrome terminal on the outlet, and then attach the ground wires to both ground terminals.