Before visiting a doctor, you can alternately apply a warm and a cold compress to the sore joint once every hour for 5–10 minutes. You can apply cream to relax the spastic muscles during a break. This will help to relieve the condition slightly and possibly unlock the jaw.
If the jaw keeps locking, you can try relaxing the chewing muscles with finger massage, applying medium force.
You can take an over-the-counter painkiller from your medicine cabinet to relieve pain.