"cloth ensign," late 15c., now in all modern Germanic languages (German Flagge, Dutch vlag, Danish flag, Swedish flagg, etc.) but apparently first recorded in English, of unknown origin, but likely connected to flag (v.1) or else an independent imitative formation "expressing the notion of something flapping in the wind" [OED]. A guess considered less likely is that it is from flag (n.2) on the notion of being square and flat.
Meaning "name and editorial information on a newspaper" is by 1956. U.S. Flag Day (1894) is in reference to the adopting of the Stars and Stripes by the Continental Congress on June 14, 1777.