There really is no one size fits all answer to this (or really any) question. Although, I’d probably suggest changing a program when it stops producing noticeable results (or when results plateau).
Now, how long that will actually take is a very individual thing. Some people might be able to stick to a given routine for years at a time and still make progress. Others might have to change things up every 3-4 weeks.
Another thing to take into account is that some routines aren’t meant to be done long term, while others lend themselves better to the long term. Personally, the more demanding a routine is on my CNS, the shorter I’ll be able to continue doing it before burning out.
As you get more experienced you’ll probably be able to tell when it’s time to change routines. But, only time and experience will give you that internal awareness. I (nor anyone else) can give that to you via an internet forum.
One last thing to consider is that “changing” a routine could be as simple as changing set/rep schemes, exercises, or workout format (changing exercise order, pairing different exercises together, adding “intensity” techniques, etc…). It doesn’t necessarily have to be a complete overhaul of the program.
Hope this helps.