Replace the battery on a battery-powered detector and press the "Test" button until the alarm sounds. Release the button; the unit should go silent. If it continues to beep, it has probably reached the end of its useful life and should be replaced.
Replace the battery on a hard-wired electrical smoke detector if only one detector out of several is beeping, and test the unit. Hard-wired electrical smoke detectors operate on 120-volt AC house power, and most include a compartment for a backup battery, in case of a power outage. If it still beeps after testing, replace the unit. Many have a plug-in connector, making it easy to change to a new unit of the same model; if not, contact an electrician to do the replacement. If all the detectors in the house are beeping, they have most likely lost power. Check for a tripped circuit breaker. If none is tripped, there could be a wiring problem and you should contact an electrician.
Reset the keypad on smoke detectors that are part of a home security system. These detectors will often make no noise themselves, but will instead cause the keypads to beep. Silence the beeping by resetting the keypad, and call your alarm company for service as soon as possible.
Clean smoke detectors of all kinds with compressed or canned air, either once a year, or whenever you change batteries. This will help prevent false alarms.