A medical doctor is the best one to answer this question. After asking the patient questions and looking at the medical history, tests can be ordered. These might include blood or urine samples and X-rays or other imaging studies such as MRI or CT scan.
There are some signs that pain is caused by a more serious problem. First, pain that is constant and never changes is a red flag. Usually, with pain caused by a muscular or other soft tissue problem, the pain can be made better or worse. Often, just changing position helps. Rest or sleeping makes it better. Certain movements or activities can bring it on or make it worse.
Anytime back pain is intense and constant, a doctor should be consulted. This is also true for pain that is present without change day and night.