If I pay credits to upgrade the strength of my ice breaker do I have to pay to do that for every subroutine or does the upgraded strength last for the whole encounter?
Whole encounter. From the rules (emphasis theirs):
This strength increase lasts only while the current piece of ice is being encountered, unless otherwise noted by card abilities. After an encounter with a piece of ice, the icebreaker’s strength returns to the value shown on its card
For most icebreakers, the boosted strength lasts for the ice, and is reset at the end of that encounter, however there are some specific ice breakers that work differently, Gordian Blade being the most notable example, the strength getting boosted for the run, though others like Study Guide don't boost like most others, they power up permanently through counter gain.
There are also other effects that modify ice breakers strength for different periods, like Security Chip, and Net-Ready Eyes. These effects have their own time limit placed on them, and that time limit is independent of the ice's boost ability.