The primary fire code writing organization is the private National Fire Protection Association or NFPA.  NFPA sets the standards for technical aspects of sprinklers installed in the USA.  Building codes, which specify which buildings require sprinklers are generally left to local jurisdictions.  However, there are some exceptions:
In 1990 the US passed PL-101-391, better known as the Hotel and Motel Fire Safety Act of 1990. This law requires that any hotel, meeting hall, or similar institution that receives federal funds (i.e. for overnight stay, or a conference, etc.), must meet fire and other safety requirements. The most visible of these conditions is the implementation of sprinklers. As more and more hotels and other public accommodations upgraded their facilities to enable business with government visitors, this type of construction became the de facto industry norm – even when not directly mandated by any local building codes.
If building codes do not explicitly mandate the use of fire sprinklers, the code often makes it highly advantageous to install them as an optional system. Most US building codes allow for less-expensive construction materials, larger floor area limitations, longer egress paths, and fewer requirements for fire-rated construction in structures which are protected by fire sprinklers. Consequently, the total building cost is often decreased by installing a sprinkler system and saving money in the other aspects of the project, as compared to building a non-sprinklered structure.
In 2011, Pennsylvania and California became the first US states to require sprinkler systems in all new residential construction. However, Pennsylvania repealed the law later that same year. Many municipalities now require residential sprinklers, even if they are not required at the state level.