What is causing me to have pain in my jaw muscles. It only hurts at nighttime when laying down. Is it an ear infection?

Bruxism? There are some people who clench their teeth and grind their teeth during sleep or unconsciously while under tension. It is also possible to have temporal mandibular joint problems which are positional in nature. Suggest you see a dentist/oral surgeon or ENT doctor and get this problem solved.