Periodic LED and on demand

The general solution is not to use the delay function. Look at the blink without delay example: http://arduino.cc/en/Tutorial/BlinkWithoutDelay