The phrase: "Do you swear to tell the truth, the whole truth, and nothing but the truth, so help you God?" is perhaps the most identified phrase heard in television court-room dramas and movies about court cases ~ that is, with the exception of "I object!" and "Sustained." Despite the fact that many people do not get into trouble themselves, forcing them to experience a trial in person, or have to serve on juries during their lifetimes, the phrase is well known. Not only is the phrase itself well known, but the fact that it's recitation is a standard element of every court case is also well known. Even people who have never set foot in a court of law seem to be aware that no court case (in the United States of America) will proceed until each and every witness is 'sworn in'.
The phrase apparently became popular on television court-room dramas from the sixties and seventies, ~ weekly night-time dramas such as Perry Mason, starring Raymond Burr in the title role. It is probably safe to say that Perry Mason was the first dramatization of actual court-room proceedings that most people ever experienced. Perhaps many people think that the phrase was created by the writers of the Perry Mason show.
The fact of the matter is that the phrase was in use long before Perry Mason became a popular court-room drama. In fact, it was in existence long before there was television. The phrase was in use during the Colonial Period of United States history. On 30 June 1775, the delegates of the Second Continental Congress meeting in Philadelphia adopted a set of rules and regulations for their fledgling militia. Titled, Articles of War, the document consisted of sixty-nine articles by which the militia would be governed. Article #54 stated that "all persons called to give evidence, in any case, before a court-martial, who shall refuse to give evidence, shall be punished for such refusal at the discretion of such court-martial: The oath to be administered in the following form, viz."
"You swear the evidence you shall give in the case now in hearing, shall be the truth, the whole truth, and nothing but the truth. So help you God."
I attempted to find evidence of the phrase from times before the Colonial Period, but was unsuccessful in my search. It may or may not have existed prior to that time. But what can be stated, with certainty, is that the court-room in which an attorney named Perry Mason practiced law was not the first to use the phrase.