One of the problems with painting a metal electrical panel is getting a good finish. If you don't use a proper primer, or do any sanding, it can be tough to get good opacity and a smooth surface. In addition, if there is any rust on the panel, you'll need to get as much of that off as you can. If the panel is exposed, and you want to paint it to match colors in the room, you can take a different approach than if you are painting a panel in a utility room or basement.
Before starting, examine the box to see that everything is in order. If anything looks amiss or there are exposed wires, call a licensed electrician who can determine if there is a safety issue.
Sand the panel well to rough up the surface and prepare it for the primer. If there is any rust, sand it off.
If the panel is exposed, and you want to use a particular color, use a liquid primer, as you will have more color options. For an interior, you will likely be using a latex for the top coat. Most primers are suited to this, but check the label just the same. If there was rust on the box, use a primer with a rust inhibitor. There are many proprietary formulations. Paint on the primer with the bristle brush, smoothing the surface with smooth, downward strokes.
If you are painting in a utility room or basement, you can use a spray primer and paint that can give you an even finish. Get a primer specifically for metal, and again, formulated to inhibit rust if there is any on the panel. Tape off the panel and surrounding wall to protect the areas around the panel. Start with a spray primer, and apply by spraying from a distance of about a foot. Keep the spray moving evenly to avoid drips. Make sure you have adequate ventilation. You may want to put a household fan in a nearby window to suck the fumes out.
Once the primer is dry, apply the first coat of paint either with the brush, if you are using liquid latex paint, or by spraying. The spray coat should go on smoothly as long as you apply it lightly. For brush application, again, go light and figure on applying at least two coats. It is better to use several light coats that one heavy coat, as this will produce a cleaner finish.
Apply as many coats as necessary to get a clean finish on the panel. Usually two is a minimum; depending on the type of paint, three or four might be preferable. You can sand the brush coat very gently between coats if you see brush or lap marks.