Stretching will help, massage is also good, make sure you properly warm up & cool down when exercising. If it's sore after exercise then ease off to let it recover properly, local ice or heat may help, and Ibuprofen can help to reduce any swelling.
Is this something which has suddenly come on? (ie after an intense session) or has it been niggling for a while?
You might want to look at your position on your bike, has anything changed recently? or if you run you could get your "gait" analysed by a sports physio or for free at one of the proper running shoe shops.
In my experience it's all about the "core" muscles, abs, back, hip flexors etc, it's surprising how many other problems can arise through poor core strength.