The town's name is derived from "ohkotok", the Blackfoot First Nation word for "rock". The name may refer to Big Rock, the largest glacial erratic in the Foothills Erratics Train, situated about 7 km (4.3 mi) west of the town.
Before European settlement, journeying First Nations used the rock as a marker to find the river crossing situated at Okotoks. The tribes were nomadic and often followed large buffalo herds for their sustenance. David Thompson explored the area as early as 1800. Soon trading posts were established, including one built in 1874 at the Sheep River crossing in the current town. This crossing was on a trade route called the Macleod Trail, which led from Fort Benton, Montana to Calgary.
In 1879, the area saw the killing of the last buffalo. Government leasing of land for one cent per acre ($2.47/km²) began in 1880. This created a major change in the region. The first settlers arrived in 1882.
A community grew around a sawmill that was established in 1891, and it would grow in size. The last stagecoach stopped in Okotoks in 1891 when rail service between Calgary and Fort Macleod replaced horse-drawn travel. By 1897 the community name had changed three times, first from Sheep Creek, to Dewdney after Edgar Dewdney the Lieutenant Governor of the Northwest Territories, and later being informed by post office authorities in Ottawa of an older settlement named Dewdney in Lower Mainland, British Columbia, the name Okotoks was chosen by local businessman John Lineham. The rail line is still a main line south to the U.S. border, but the last of the passenger service (Dayliner unit) ended in 1971.
In 2007, the energy efficient Drake Landing Solar Community was established in Okotoks.
Numerous old buildings have been restored, and one house was even resituated blocks away to avoid destruction by the widening of the highway through the townsite.