I saw this mentioned briefly in another thread. Aside from being totally horrible, why would this be a thing? Did they think it led to the 'truth', or was it simply tradition/custom?
The practice of torture (in general) during testimony was called basanos in Greek, which originally meant something like "test" or "proving." Not only was it thought to lead to more pure truth, but it was much preferred over the testimonies of free citizen witnesses, supposedly, though some doubt it was actually used very often in practice. The threat of it was ever-present, though. From the Classical Athenian orator Demosthenes:
Indeed, you all consider duress the most accurate source of testimony in both private and public affairs; and when slaves and free men are both available and you want to find out an item under investigation, you do not use the testimony of the free men, but you inflict basanos on slaves, so you can discover the truth. And this is reasonable, jurors, for you know well that in the past some witnesses have seemed to lie, whereas no one subjected to torture has ever been proven to tell a lie. (Dem. 30.37).
It is a form of evidence and it would have usually occurred in a dispute involving two parties. Aristotle calls it a pistis ("proof")(Rhetoric 1.15). The slaves in question would pertain to one or the other party (ie random slaves off the street who happened to be near a crime were not brought in via basanos). The interrogation could be carried out by either party, or a third party specially chosen for the purpose, wonderfully called a basanistes. The slave replied to questions with a yes or no, only.
Most of our evidence for this custom comes from the late 5th century, in anecdotes told by Athenian orators. We hear of no actual cases of basanos being used, though a few times we hear that a request was made and accepted, but an agreement was reached before the basanos was necessary. Not even in the deadly serious case of the hermokopidai (the smashing of dicks off statues of Hermes in the city on the eve of the expedition to Sicily in 415 BCE) was evidentiary torture employed. Like many aspects of the ancient world, this practice is enigmatic and we just don't know for sure how it worked, or when it actually happened.
The practice has obviously been widely condemned in the pre-modern and modern West. Remember that slaves in the ancient world had no rights whatsoever and were subjected to all sorts of blood-curdling cruelties. As a class they were assumed to be liars, cheats, deadbeats, worthy of absolutely no consideration. Their testimony under torture was valuable because it was derived by that most effective method: pain; it was a source of information lacking from the freeborn, who had rights and privileges.