Before a witness can give testimony in the courtroom, the witness will be put "under oath." The judge might give the oath, but usually the court officer will. The witness will be asked to stand and raise the right hand, just like on television, and whoever is giving the oath will say:
"Do you solemnly swear that the testimony you are about to give will be the truth, the whole truth, and nothing but the truth?"
Sometimes, whoever is giving the oath will also say, "So help me God," but it is considered a little old-fashioned to add that part these days.
Sometimes, whoever is giving the oath will also say, "Under the pains and penalties of perjury." It all depends on who is giving the oath.
What does the Oath mean?
The oath is meant to impress upon the witness that what they are about to talk about is not just everyday conversation, but can affect the lives of other people.
What if someone lies under Oath?
If someone lies under oath at a hearing, there are real penalties. First, and most likely, the judge might simply disbelieve everything else that witness says. You can imagine how harmful this can be for a witness’ testimony! Second, the court could find the witness in contempt on the spot. Contempt means that a person is either violating a court order or disrespecting the legal process so completely that is the equivalent of breaking the law. Occasionally, a judge will send someone to jail immediately. The judge will tell the court officer to place the witness in custody - and the witness will be led to the jail cell in handcuffs! This is very rare, though. More often, the sanctions for contempt will be a fine. This sanction is very much in the discretion of the judge.
TIP: If you are asked a question under oath and are not sure of the answer, don't pretend you know! Let the judge know that you are not 100% sure of the answer. Then you can explain what you think the answer is and why you are not sure. This is much safer than guessing.