Gold studs are a component of formal dress uniforms in several branches of the military as well as some uniformed services, but there is no single universal rule regarding which uniforms they are to be worn with or even if they are considered mandatory purchase items.
In the United States Navy, gold studs are basic components (i.e., they are required) for both male and female Officers and CPOs when wearing the Navy Dinner Dress Jacket (blue or white), but are optional with the Dinner Dress Blue Uniform with the Service Dress Blue Coat. The U.S. Maritime Service follows the Navy’s regulations, while the Army lists gold studs as optional purchase items that may be worn with the Blue and White Mess Dress uniforms and the Blue Dress uniform.
Coast Guard personnel may wear gold studs with Dinner Dress Jackets (White or Blue) and the Formal Dress Blue uniform; oddly, the Coast Guard Auxiliary regulations call for silver rather than gold studs. Members of the United States Public Health Service Commissioned Corps are required to wear gold studs with uniforms that also call for gold cuff links (similarly, they are optional wear items on uniforms for which cuff links are considered optional).