It depends really on whether they're actually doing the exercise
you set in Spanish and so not practising their English. Or, whether they are using Spanish to discuss the task
, ie meta-language.
In the case of meta-language, you can present and practise useful phrases (eg What did you put for number 4? I don't agree. I think it's ... Could you pass me the ...) as you would any other language point.
It's important to give them lots of practice and to get the pronunciation correct. You can follow this up in later lessons and keep the language posted in your classroom as a reminder.
Then make sure that this language is used in the classroom whenever possible, eg when checking homework.
If your students are using Spanish to do the task itself, you could look at whether they have the language necessary to do it in English. Make sure you have foreseen, presented and practised all vocab and structures needed. Also think about whether the task set is of the right level. If it's too high, they won't be able to do it in English. If it's too low, they might not feel motivated to make the effort.
If this doesn't work, you need to take remedial action. Photocopy a sheet of paper with large crosses on it. Cut out these crosses, so you have a series of "tokens" you can hand out. As soon as somebody speaks Spanish, give them a cross without saying anything. At the end of the lesson ask them to count up how many they have and if they know why. then have a discussion (possibly in Spanish!) about their reasons for using Spanish and the importance of using English.
You can continue using these crosses and could also add rewards in later lessons for those who make the effort.
Hope that helps!