Audrey, you have several options, depending on how far it's been pulled. If it's a pretty large loop that had made up several stiches, you can either cut or use a hot glue gun to re-attach the yarn to the surface. If you hot glue, find the "run" (i.e. panty hose run), and put a strip of masking tape over the yarn to each side of it. Then place a bead of hot glue in the run. Using tweezers or similar (hemostats work nice if you have them), re-create the loops, tucking them into the glue. Then go back between each loop and put a dab of hot glue in, in effect lacing over the yarn side to side.
If the carpeting will not show the run, you can cut by holding your scissors flat to the surface of the carpet and clip off the pull. Finish by dabbing the clipped ends into a bead of hot glue on the backing surface. This will "lock" the ends down to prevent spreading.
If the pull is not large, you can use tweezers to re-adjust the loops, by pulling the yarn in the adjoining, small loop back through. (Trying to think of a good explanation to describe here) In other words, if you have one large loop, it in part came from the loops beside it; provided those loops haven't totally come through, you would pull them back to restore the normal size loop. Good Luck!