You should swap out smoke-alarm batteries at least once a year.
Per the US Fire Administration, you should swap out the batteries in your smoke alarm at least once annually and replace the alarm itself after 10 years.
The administration also recommends testing fire alarms once a month to make sure that they work.