There’s no definitive answer. It really depends on what you like. Some people like a dead sound and never change their strings. Others prefer the bright zing of new strings and might change them every two weeks. It also depends on how much you play. The more you play, the sooner the strings will wear out. I would recommend the average bass player playing an hour a day should change (or clean) his or her strings every 2 to 4 months.
The reason strings go dead is over time oil, sweat and dirt accumulate in the grooves of the strings. Try to avoid playing your bass with dirty hands and your strings will last longer. Many people wipe them down with a soft cloth after playing.
Follow this link to see how to change bass strings correctly.