There is little federal legislation on this matter, and a number of states have their own laws regarding storage of firearms. Regardless of law, though, it is always a good idea to store firearms under some sort of locking device and inaccessible to minors and others not authorized to use them.
Be sure to check the regulations of your specific state and err on the side of caution.
The Protection of Lawful Commerce in Arms Act (2005) makes it unlawful for licensed manufacturers, importers, and dealers to sell or transfer a handgun without providing the transferee a secure gun storage or safety device, however, there is no federal law requiring these devices to be used in the home. Eleven US states have laws regarding firearm locking devices that differ from each other, so be sure to check the regulations in your state regarding storage if you currently own or plan to purchase a firearm.