I think the best reason to do it during the regular season is to teach players not to foul.
Otherwise I think a decision process should be used. Is this player foul prone, is there a difficult matchup making fouling more likely, are these officials calling questionable fouls, how badly do we need them out their now (are we falling behind by a large margin...). Also I would vary it (especially late in the season) depending on how likely we are to need to push every advantage. If we are likely in trouble take more risks, leave the player with fouls more exposed. If we should win even with them missing extra time, ok be more willing to pull them.
In general, I think coaches pull players much too often due to foul trouble. Unless the player is foul prone it seems they often pull the player with 2 fouls in the first half and they never even pick up a 3rd foul in the second half. That just makes it seem like a bad in game tactic. The one exception is for a season long strategy of teaching the players not to foul.
One way pulling a player earlier for 2 fouls in the first half or 3 or 4 in the second is to spread out the time of the reserve. If there are 12 minutes left in the first half and there is really 1 reserve that needs to take the time this player is out, pull them now, let the reserve get 4 minutes in and bring the player with 2 fouls back (maybe for 2 or 3 minutes). Especially if the reserve almost always plays in short 3 or 4 minute spurts don't create a situation where they need to play 12 straight minutes or something (protect, not just them getting tired but the other team figuring out how to exploit them).
Related: Frank Kaminsky, College Basketball Player of the Year - Lessons for Managers from Wisconsin and Duke Basketball - Why Do People Fail to Adopt Better Methods? (underhanded free throws) - Universities Again Abandon Fans/Mission to Increase Pay to Administrative Staff/Coaches