方程 is equation/formula. 方程式 is listed in the dictionary as an alternate form of 方程. So there is no inherit difference in meaning, its just a matter of which you encounter more frequently. I do think you are unlikely to encounter 方程式 in the names of formulas, since those are nouns themselves and not people choosing vocab casually, if that makes sense.
Both can be used without the context of math, for example chemisty or physics equation/formula. I don't think grammatical equation/formula would be a valid use, simply because I don't think grammar has those type of formulas and equations.
If not sure which to use, I think it would be safe to stick with the standard 方程。
P.S. 方程式 has an additional definition for formula car racing, but this is unrelated to your questions context-- just mentioning it as a side context. in this case it is saying formula style racing, using 式 more standardly.