This is a very good question and one that I have struggled with for most of my career. I do not think that you can always differentiate the two.
Also, pain from the muscles can be a sign of a problem deeper in the skeletal system. I see this a lot. Usually the history helps me differentiate. Muscle strains usually happen fairly suddenly and often improve fairly quickly (although not always.).