How pain can stimulate the vagus nerve
Short answer
Given your comments you are referring to the cause of fainting after being triggered by certain stressors. The reason is a sudden drop in blood pressure due to parasympathetic nervous system activation (vagus nerve activity). This leads to reduced blood flow to your brain, which results in a brief loss of consciousness (Mayo Clinic).

Background
There are various types of fainting (syncope) with various causes. The type you are referring to is neurally mediated syncope (Arthur &amp; kaye, 2000). It is evoked by emotional activation due to stressors (pain, fear etc.) Stress responses are accompanied by the release of stress hormonses, most notably Adrenaline (epinephrine). Epinephrine release results in sympathetic nervous system arousal, resulting in increased blood pressure, increased pulse and sweating. It also increases amounts of blood being funneled to peripheral organs. These mechanisms aids in the fight,fright and flight response, as more blood in the periphery allows more glucose to be transported to the muscles (Agarwal, 2007). The funneling of blood in the periphery (venous pooling), however, can reach a point in which venous return of blood to the heart falls too sharply. This in turn can lead to a substantial increase in the muscle activity in the ventricles, as they are likely struggling to pump the small available amounts of venous blood into the heart chambers. The increased muscular activity in the ventricles is believed to activate mechanoreceptors that would normally fire only during stretch. 

Stretch of heart muscle is normally associated with a high blood pressure. The warning message of a high blood pressure by the mechanoreceptors is sent to the medulla in the brainstem, which in turn leads to parasympathetic nervous arousal. As a part of the parasympathetic response, the vagus nerve is stimulated which reduces heart activity to reduce blood pressure. 

However, when the mechanoreceptors are stimulated due to the overt contractility of the ventricles due to a low blood volume, they sent the same neural input to the medulla which normally signals hypertension, thus causing vagus nerve stimulation and hence a paradoxic parasympathetic arousal that results in low blood pressure (hypotension), low heart rate (bradycardia), and ultimately fainting (syncope) (Grubb, 2005). 

References
Agarwal et al., Postgrad Med J 2007;83:478–80
Arthus &amp; Kaye, Postgrad Med J 2000;76:750-75
Grubb, Circulation 2005;111:2997-3006