please give me a pointer if this has been covered I have looked but searching is not easy as all the search terms occur many times

the question is: what should I do (as a rule of thumb) if I have a pocket pair and another pair shows up on the flop?
The genreal rule (elsewhere on the forum) seems to be fold if you miss the set.
Instinct tells me that if a second pair is flopped then I should fold an underpair and raise an overpair.

The whole situation makes my head hurt

I have to take into account the danger of someone having trips against the
probability of me having the top hand with the possiblity of drawing a full house. Does the 3rd Card matter ?

Advice appreciated.