Usually these two forms are synonymous (while the infinitive form is usually the native choice). However, sometimes they produce differences:
I use it when I have to grind something for cooking.-- Probably grind e.g. an herb for cooking a meat dish. In other words, it sounds to me a bit like the speaker is grinding something in order to cook generally or to cook something else.