Every state may be slightly different. To find out the exact wording and rights provided in your state statutes, call up your state senator or representative and ask to be given a copy of your state’s laws on affirmations and alternatives to secular oaths. Many states have a legislative reference bureau or its equivalent, which can also direct you to the current statutory wording. (You can search online yourself, but be aware that old laws can stay on the books and be misleading.)
If you are summoned for jury duty, seek out the bailiff and explain that you have a conscientious objection to taking a religious oath. Prospective jurors are generally sworn in en masse, which does not permit you a chance to actually avoid a religious oath. Ask the bailiff to follow that group oath with an affirmation. Ideally, the bailiff should announce there will be two options. You should be sure the bailiff understands that an affirmation does not mention a deity. You will probably be asked to affirm to the “pains and penalties of perjury.” If the bailiff is uncooperative, you may ask to speak privately with the judge. You may also write the judge beforehand with your request and ask how your rights will be protected.
If you are testifying at a trial or hearing, you also have right to affirm in most states. If you are given an oath with a deity in it, and a bible is held up for you to place your hand on, inform the judge that you need to make an affirmation (and mention that you would be glad to place your hand on the U.S. Constitution instead!). It is unfortunate that the onus falls on you to object, and thus to single yourself out as a nonbeliever, or at least a non-swearer, often in front of a jury. Some enlightened judges have dropped religious oaths entirely, but that is rare.
The U.S. Constitution prohibits a religious test for public office in Article 6: “no religious test shall ever be required as a qualification to any office or public trust.” Judicial decisions apply. The U.S. Supreme Court issued a unanimous ruling in Torcaso v. Watkins, 367 U.S. 448 (1961), in a case brought by a nonbeliever in Maryland who was given a religious oath when he applied to become a notary public. The Supreme Court ruled that the First Amendment to the U.S. Constitution, which is applied to state and local governments by Amendment 14, prohibits government was forcing a person to profess a belief in God or in any religion as a condition of obtaining public services or benefits. Despite the Torcaso decision, a few states are holdouts and have retained unconstitutional religious tests for public office, for jury duty, etc. However, there have been a variety of lower-court decisions on the matter, including People v. Velarde, 616P.2d 104 (1980), in which the Colorado Supreme Court held that, although jurors are required to state affirmations, they are not required to swear an oath to a god.