On June 14, 1777, the Second Continental Congress passed the first Flag Act: "Resolved, That the flag of the United States be made of thirteen stripes, alternate red and white; that the union be thirteen stars, white in a blue field, representing a new Constellation." The story that Betsy Ross's descendants argued in the 19th century was that she designed it; more likely, Congressman Francis Hopkinson did, but in any case it had the approval of Gen. George Washington. The motion was brought to the floor by future president John Adams.
After that, both stars and stripes were added as new states entered the Union, but soon it was clear that the flag would be overburdened with stripes, so an act of April 4, 1818, signed by President Monroe, provided for 13 stripes and one star for each state, to be added to the flag on the July 4 following the admission of each new state.
There was no uniform arrangement to the stars in the canton in the 19th century, perhaps befitting a sprawling, individualistic nation. But President Taft signed an executive order dated June 24, 1912, establishing the proportions of the new 48-star flag and the arrangement of the stars in six horizontal rows of eight each, a single point of each star to be upward.
In 1959, President Eisenhower signed two executive orders (dated January 3 and August 21, respectively), providing for the arrangement of the stars in the 49-star flag and then the 50-star flag still in use.
As for Flag Day, the day had been celebrated in various ways in various places in the 19th century -- again, that refreshing lack of standardization -- but in 1916, President Wilson proclaimed an official Flag Day. In 1949, President Truman signed an act of Congress designating June 14 as National Flag Day.