In Germany there are fairly wide-ranging reasons to legally refuse to testify; close relatives and spouses don't need to help prosecuting their loved ones and it is legally impossible to put an accused under oath.
Even if not accused, one can legally refuse to testify (let alone under oath) if that statement would be self-incriminating.
But your question surely concerns situations where none of the above applies.
Par. 70 of the German code of criminal procedure specifies, equally for witnesses who refuse to testify at all, or refuse to testify under oath:
- The witness owes the costs that have arisen because of their refusal;
- the court can impose a fee (leading to incarceration if it cannot be collected);
- the court can order an arrest right away to enforce the court order. The duration of the arrest cannot exceed the duration of the trial and cannot exceed 6 months.
Certainly, as always, the implicit Basic Law rule of proportionality ("Verhältnismäßigkeit") must be considered. That principle limits all government action to be as mild as possible when regulating peoples' lives. It is similar to the Eighth Amendment, but more comprehensive, and immediately applicable law.
In this particular case it certainly means that the enforcement measures cannot qualitatively exceed the expected punishment/compensation. If the suit is about stealing an apple it would probably be illegal to arrest an unwilling witness, even if we consider that there is additionally a general interest in our social order to pursue and sanction crimes. If, on the other hand, it is about murder, and the statement is decisive, the court will likely exhaust its available enforcement measures.
As an aside, there is an amusing scene in the German film Stammheim where a witness defies the judge's order to testify. He says "Ich muss hier gar nichts" ("I don't have to do a thing here") and is lectured ("please inform him about the consequences") and threatened with enforcement arrest and fines. I'm not sure about the witness's identity but I must presume that he already serves a long sentence for his "political fight" (i.e., terrorist activity) so that the threats of enforcement are not the sharpest blade in the judge's arsenal.
An interesting detail is that at that time (1977, probably) apparently the court could refrain from demanding an oath if the defendants agreed. That "Ziffer 5" must since have been removed from §61 of the Code of Criminal Procedure (StPO).