Electrical boxes serve as end or transition points for electrical wires. Outlets, light switches, lights, and ceiling fans are but a few of the devices that are installed in electrical boxes.
While there is an endless variety of sizes and shapes of electrical boxes, all can be divided two camps: plastic or metal electrical boxes. To confuse matters, your choice of plastic vs. metal is clear-cut in only a two instances, with other instances being at your discretion:
1. When To Use: Plastic Electrical Box
Use a plastic box when you have Romex (or NM) wiring leading in or out of the box.
Metal-sheathed wiring depends on bonding with the metal electrical box for grounding. Using metal-sheathed wiring with plastic electrical boxes severs that ground and is highly dangerous.
Easy for do-it-yourself home renovators to work with, plastic electrical boxes come with pre-attached nails for nailing into studs, "wings" so they can be attached directly onto drywall (called old work or remodel boxes), or metal brackets that attach to the studs but are adjustable in/out with a Phillips screwdriver.
Many do-it-yourself electricians may find it easier to work with the plastic electrical box in conjunction with Romex or NM wiring. Plastic boxes are lighter and their holes are easier to knock out.
On the downside, plastic boxes have a tendency to become misshapen when stressed.
Remodel (old work) boxes attached to drywall can pull away from the drywall.
2. When To Use: Metal Electrical Box
Use a metal box when you have metal-sheathed or "BX" wiring leading in/out of the box. However, metal boxes can also be used with Romex or NM wiring, if desired.
The metal electrical box is well suited for metal-sheathed wiring. This type of wiring depends on the contact from its metal sheathing to the metal box to complete grounding.
However, NM or Romex wiring does not use its sheathing for grounding: it uses a bare wire contained within the sheathing. Contact between the device (light switch, outlet, etc.) and the metal box completes the ground. As such, Romex or NM wiring can be used either metal electrical boxes or plastic electrical boxes.
You should also use a metal box when the box will be exposed beyond your finish surface.
Metal boxes are strong, plus they provide a strong attachment with the stud. They will not distend, nor will they pull away from the stud when properly attached.