There are different kind of jaw pain. It could be the joint (TMJ) or the muscles or both. Most jaw pain is related to an incorrect bite causing damage to the joints and muscles of mastication (chewing muscles).
If the teeth are not aligned with each other in a comfortable position of the jaw, or when upper and lower teeth come together either for chewing or when clenching or grind at night, they slide with each other and the pressure transfers to the joints and muscle causing TMJ issues.
There are different ways to resolve bite issues however the most predictable way to diagnose the problem is to do a bite study.
There are different ways to correct the bite and the three major ones are bite adjustment, teeth alignment, and restorations. A Night Guard could be helpful as a preventive device only if they are made properly and adjusted to the bite.