Following the death of John Sevier in 1815, Cocke ran for his vacant seat in the U.S. House of Representatives, but was narrowly defeated by William Grainger Blount, 1,583 votes to 1,355. He ran against Blount in 1817, but was again narrowly defeated, 3,627 votes to 3,429. In 1819, Blount decided not to run for reelection, and Cocke was finally able to win the seat, edging James Porter, 3,792 votes to 3,434. He ran opposed for reelection in 1821 and 1823. In 1825, rising anti-Jackson politician Thomas D. Arnold challenged him for reelection, but Cocke won by a vote of 4,770 to 3,343. A Democratic-Republican, Cocke served in the Sixteenth, Seventeenth, Eighteenth, and Nineteenth congresses. During the Eighteenth and Nineteenth congresses (1823–1827), Cocke was chairman of the House Committee on Indian Affairs.