The hamstring is three muscles, semitendinosis, semimembrinosis and the biceps femoris, located near the back of your legs and above your knees (See References). A hamstring can be pulled when the muscles are torn or stretched. This can be a common injury for golfers and can be caused by having bad form when swinging or putting too much pressure on the muscles when walking a course.
Get off your feet as soon as you experience any pain in your leg or feel that you could be injured. Go to the club house or have a friend drive you there. You don't want to risk making the injury worse.
Determine if you are experiencing pain near the region of your leg behind your thigh. Check for swelling and ice the area. Don't wait until you get home to ice the swollen hamstring. Also, such minimal pain for a torn hamstring is called a "Grade 1" pulled hamstring and it recommended to wear a hamstring compression support bandage until the pain ceases (See References).
Try walking a short distance after icing and once the swelling has gone down. If you can't walk without a limp it's possible that you have a Grade 2 pulled hamstring. You will also feel more pain and you should immediately need to elevate your leg. Ice for 48 hours and walk with crutches if you need to go somewhere (See References).
Observe the swollen hamstring closely. If you can't get a decent look at where the pain is then you should try using a mirror to look at the area. If you notice a large bump and feel extreme pain then you could have a Grade 3 pulled hamstring. You will also have more trouble walking and most likely not be able to walk at all due to the pain.
See a medical professional for Grade 2 and 3 pulled hamstrings. Grade 1 can typically be treated on your own. The doctor should be able to help your with any medication and stretches that you'll need to perform once the hamstring muscles have fully healed.