Relax. They are more than likely harmless. Some fish will actually snack on them. I found a source online that said most worms seen outside the fish are usually not internal parasites and not considered harmful to fish. Parasitic or harmful worms wouldn't be visible on glass or gravel. One way to control their population is to clean the tank regularly and avoid overfeeding.