Which flag? If you mean the Stars and Bars, this was created in 1861 during secession as a proposed design for the Confederate flag, and was adopted on March 4, 1861 by the Provisional Confederate congress.
If you mean the Confederate Naval Jack/Army of Northern Virginia battle flag (the most frequently used flag to represent the Confederacy), a variant of the flag was a rejected idea for the Confederate flag, and was later modified to be used as a battle flag, with a variant of lighter blue used as the Naval Jack. The first time it really popped up as a symbol of the Confederacy after the Civil War was in 1904, when it was first flown by Southern states to show their support for segregation laws.