PIC12F675 micro controller programming
The problem is that you are using a delay function in your code. While this is running the program is in a continuous loop and can do nothing else, including reading your button. This is bad practice but unfortunately it is promoted by all the basic tutorials on micro programming - particularly on the Arduino platform.

Here's some pseudo-code to get you thinking:

void setup(){
  long t0;                // The output timer.
  long onTime = 2000;     // ms
  long offTime = 15000;   // ms
}

void main(){
  while(1){
    if (sw){                // assumes that 1 == released.
      out = 0;              // output off immediately.
      t0 = millis();        // assumes that there is some sort of millisecond clock in the device.
    } else {
      if ((millis() - t0) &lt; onTime) {
        out = 1;            // on time
      } else {
        out = 0;            // off time
    }
    if (t0 &gt; (onTime + offTime)){
      t0 = millis();        // Reset the timer.
    }
  }
}


Now you should be able to do other stuff while periodically checking the button status and updating the output.