Either make them roll for it, or explain why it wouldn't work at all
The general rule is roll when the outcome is in doubt. This means players don't need to roll when there's no chance a spell would fail, but it also means they can't roll if there's no chance it would succeed. No regular student is fast or powerful enough to cast a counterspell against Voldemort, for example. There's simply no scenario where that could succeed
If you can't think of any reason the spell would fail (which would trigger a roll) or simply not work, you should let the players cast it successfully
Other things to think about: What are the results of using the counterspell? What new problems does it create? What new mysteries does it uncover? How does it spark the next step in the adventure? And, when saying something won't work & players can't roll for it, always make sure you offer an alternative. Players can't counterspell Voldemort, but maybe they could evade or trick him instead