A viral infection. Herpes simplex virus type 1 usually causes cold sores on the lips. Type 2 usually causes genital herpes. However, herpes virus is an equal opportunity virus, so type 1 sometimes causes genital herpes, and type 2 sometimes ends up causing lip sores, depending on what kinds of activities a person participates in. Pre-teen children's cold sores are non-std's. They get the virus from family & friends.
Herpes Reactivation. The virus (hsv-1 or hsv-2) "hides out" by integrating its dna into the dna of sensory neurons. When stress (surgery, infection, treating skin badly?) signals the neuron to do something, these same signals also "reactivate" the virus to replicate and release virus particles onto the skin hence, painful/itchy fluid filled vesicles. Similar to (but not exactly like) rats leaving a sinking ship.
Secondary to HSV. Cold sores are secondary to HSV (herpes simplex virus-1). It is sexually transmitted usually from kissing an infected individual. 85% of adults have this virus even though it may not fully manifest as cold sores. Although not curable they can be controlled with topical and /or oral medication. Monogamy is really the only prevention. Multiple partners increases your risk.