Why doesn't local anesthesia affect muscles?
@Nicolai's answer is not entirely correct.

Background

The most common local anesthetics are all the "-caine" drugs - like novocaine, lidocaine, - and even cocaine has some of the same pharmacology, as well as other effects (in movies this is why cops might rub some white powder on their lips - if it's cocaine, it will make their lips tingle; this is not standard training for non-movie police; also not advised for drug sellers or purchasers, because for exactly this reason cocaine is often cut with other -caines or other compounds that give a tingly feeling).

What all of these drugs do is to block voltage-gated sodium channels. These are the channels that propagate action potentials through axons and excitable dendrites. Other local anesthetics that aren't used in the clinic, like tetrodotoxin from pufferfish, block the same types of channels. At sufficient concentrations, local anesthetics block all nervous activity: unlike @Nicolai's answer, they do shut down nerves (as a brief note for terminology: nerves are bundles of axons containing many many individual fibers).

So back to your original question: how come the muscle isn't impaired during dental surgery?

Geometry of innervation of the face

Take a look at this picture of the nerves innervating the facial muscles and the muscles themselves: https://bmc.med.utoronto.ca/cranialnerves/wp-content/images/c_07/Facial-vii12_labelled768.jpg (note: I wasn't able to find a good image that has a license allowing me to reproduce it here; if someone finds one and wants to edit it in, please do - thanks!)

They mostly come in from the sides of the face, and so they are further away from the site of local anesthetic injection. The muscles themselves also extend further away. It may be that the muscle is partly anesthetized, but you don't realize it.

Limited diffusion and location of injections

Diffusion of local anesthetics is limited because they actually act inside cells, and only the unionized form can diffuse across cell membranes. Once inside the cell, the tend to be ionized and therefore get "stuck". Therefore, they don't typically diffuse nearly as far as other compounds of similar size, especially lipophilic compounds.

The nerve endings that sense pain, on the other hand, have to be at the surface of the skin/mucous membranes. That is, they are exactly where the local anesthetic is being injected. The objective of local anesthesia is often to inject enough to affect only those surface tissues, trying to spare the deeper tissues.

Effects on nerves

However, it isn't too uncommon to overdo it and to paralyze the underlying muscles or nerves. Even nerves far away can be affected, for example see this paper discussing cases where the local anesthetic travels near the eyes and impairs eye movement. There are also other non-dental procedures where block of a particular nerve is the intended result: this can be seen as an alternative to general anesthesia. One example is the use of an epidural (essentially into the space around the spinal cord) injection during childbirth or surgery. The extent of paralysis depends on the dose, however, and usually the intent is to avoid major paralysis and use other drugs like opiates to assist in preventing pain.