Have you taken a look at the ESP8266 Arduino examples?
in the examples shows how to remotely update the running sketch from an HTTP server.
https://github.com/esp8266/Arduino/blob ... Update.ino
Also recommend reading the docs page on the "HTTP Server" update section https://github.com/esp8266/Arduino/blob ... ttp-server