How often should you replace the sand in your pool filter if replacing it causes foam in the pool?

It sounds like you may have phosphates in the water, do you have lots of leaves or the aftermath of seeds from the trees blowing in your area, I had poplar tree seed casings white fluffy things and it gave me this problem. Solution is a product called phosfree. I always change my filter's sand once per season, unless there is a high concentration of leaves and other debris being vacuumed up daily. Then I will change it out mid-season as well. After changing the sand, I always backwash the filter for at least 5 minutes. That way the pulverized dust and other small particles in the sand get whisked away, instead of going into the pool. The sand under normal use should last 5 to 10 years if it's backwashed well enough. The foam could be caused by the algaecide used. The usual reason for replacing the sand is when sand is returning to the pools or it is no longer effective. You should check with your local pool chemical supplier. Most pool sales and service companies supply free water testing when you are a customer.