On April 15, 1965, the NFL changed its official penalty flag from white to bright gold. There were a few reasons that this change occurred.
The first was that the majority of the officials wore white hats back then, and these hats were used as a tool to mark spots of fumbles, out of bounds, etc With the advent of television broadcasts of games becoming more and more common, spotters in the stands would have an easier time discerning between a marker of a spot and that of a foul. A recent article on ProFootballTalk.NBCSports.com states that a second reason was that, sometimes, littered paper from the stands, mostly white, was mistaken for penalty flags. I would imagine that games played on a snowy day would be impaired by the color white as well.

The American Football Database reports that the idea for the penalty flag originated with Youngstown State coach Dwight Beede and was first used in a game against Oklahoma City University on October 17, 1941. Before flags were introduced, officials used horns and whistles to signal penalties. The flag was officially adopted at the 1948 American Football Coaches’ rules session.
The National Football League first used flags on September 17, 1948, when the Green Bay Packers played the Boston Yanks. The college game used red colored flags until the 1970’s, and the striped rules enforcers in Canada carry an orange flag. As for the hat being used for spots… this practice has decreased over the past four decades, with beanbags ranging from white to black and most commonly blue.
