You can just have a variable that remembers whether the alarm is
supposed to be on or off. Let's call it alarm_on. Then:
bool alarm_on;
static void start_alarm() { alarm_on = true; }
static void stop_alarm() { noTone(); alarm_on = false; }
void loop()
{
if (alarm_on) alarm();
if (some_condition()) start_alarm();
if (some_other_condition()) stop_alarm();
}
For a better approach that allows you to sound the alarm without blocking the whole program, see the Blink Without Delay Arduino tutorial.