There are no hard and fast rules over when you should change your electric guitar strings, to be honest. Most casual guitarists do it once every two or three months, but if you’re a more serious player who’s putting in a few hours of practice every day and gigging regularly, you’ll probably need to change them more often.
It also depends on how you want your strings to sound. If you want them to sound at their absolute best for a recording session or tour, then you might want to replace them every few days. Electric guitar strings have a small window where they sound their very best, so it’s a good idea to make the most of that.