iPhone owners with the problem can enter their phone's serial number into Apple's support website and, if the phone is eligible, the company will repair it for free.
Apple said the on-off -- or "sleep-wake" in Apple parlance -- issue affected only a "small percentage" of iPhone 5 users, causing the button to work intermittently or to flat out stop working.
The replacement move is rare for Apple, but the company has made this type of fix before. After it released the iPhone 4 in 2010, Apple responded to widespread complaints about faulty antennas -- and a media frenzy dubbed "Antennagate" -- by giving owners free cases to alleviate the problem. Last October, the company recalled flash memory drives on certain models of the MacBook Air. And in 2011, Apple recalled MacBook MagSafe power adapters that were prone to splitting.
For customers in the US, the replacement program starts today. For those in other countries, the fix will be available May 2. Users can either take their phones to Apple retail stores or other official Apple dealers, or mail them in.
But there are some restrictions. For example, if the phone had been been damaged in a way that affected the on-off button, that issue needs to be resolved before the button replacement.