What is the origin of the oath to tell the truth the whole truth nothing but the truth?

In modern law, those words, preceded by the words "I swear", indicate that the sworn testimony of a witness will follow. Taking oaths before something that is sacred to the witness is an ancient concept in law that has evolved from ancient times. People have have taken that type of oath since ancient times with their hand holding or resting on something sacred to them with their other hand raised. The sacred object lends a greater than usual care in doing one's duty by telling the truth although it is not required in modern times in many jurisdictions. Five hundred years before the common era the Romans swore oaths upon the Jupiter Stone in the Temple of Jupiter. Oaths are mentioned in the Old Testament. Therefore, they were already in existence at that time. The form mentioned in the question is the modern form.