The hamstring is a collection of three mostly biarticular posterior thigh muscles that provide the dual action of knee flexion and hip extension. Shown below, highlighted is the biceps femoris head of the hamstring and the semitendinosis and semimembranosis heads are also seen adjacent.
The primary function unique function in running is to halt forward leg (thigh and calf) motion in the terminal leg swing (noting this guy’s R leg).
I can’t comment about the specifics of how the HS is used in the other phases, but braking of the terminal leg swing is a biarticular action that is consistent with the action of the HS and seems to be the phase that causes my pain. Note that in the other phases, the quads, glutes and calfs all perform some action that would be antagonistic to the biarticular (knee extension, hip extension) action of the hamstring.
The highlighted text is my observation and opinion and but makes some sense.
Useful hamstring links