In my experience, adding an airstine eliminates the foam.
I have a similar set up with a hang on filter and i think that the water flow from the filter helps to create it.
It is a sign that there is not enough oxygen in your water so you need to create some.
An airstone will break the surface of your water which will eliminate it.
If left i think it will act as a pollutant and create bad water parameters which will be harmful for your fish