New building regulations will apply from October this year.
The devices, which detect the presence of the so-called “silent killer”, will have to be installed when boilers, heaters, cookers and fires are fitted in houses, hotels and care homes.
At least 50 people die every year from carbon monoxide poisoning in the UK.
The Scottish government’s planning minister, Derek Mackay, said: “Not a year goes by where there isn’t an avoidable death in Scotland from carbon monoxide poisoning caused by faulty heating appliances in buildings.
“There are also a considerable number of incidents where people are treated in hospital for the effects of carbon monoxide poisoning.
“That is why, from 1 October, the Scottish building regulations will require carbon monoxide alarms to be fitted when a new or replacement boiler or other heating appliance is to be installed in a dwelling and other buildings with bedrooms.”
Louis Blake, from the Carbon Monoxide – Be Alarmed campaign, added: “An audible carbon monoxide alarm is the only way to protect yourself and your family.
“This change to the Scottish building regulations will see more detectors in Scottish homes, which will save lives.
“However, we urge people to act now to protect themselves from carbon monoxide and buy an alarm today.”
Carbon monoxide cannot be seen, smelt or tasted.
Combustion appliances fuelled by solid fuel, oil or gas all have the potential to cause carbon monoxide poisoning if they are poorly installed or commissioned, inadequately maintained or incorrectly used.