I was reading a book a few years ago (can't remember the name or author) about a roman centurion. Characters in the book would quite frequently either kill themselves, or be ordered to kill themselves (often for VERY petty reasons). How accurate is this?
Being ordered to kill one's self was more common in the Empire than the Republic. Most emperors, especially the crazy ones, jealously guarded their power and were wary of a general getting too popular. Despite swearing an annual oath of loyalty to the Emperor the troop's favor could always shift if the emperor was weak and their general was talented. This can be seen in Nero ordering the death of Corbulo.
Corbulo was successful in subduing Germanic revolt and shortly after his appointment as governor of Asia invaded Armenia and Rome was able to install a vassal king. Nero summoned him back to Rome and on the journey a messenger intercepted him with a message from the emperor with instructions to kill himself. Upon reading the note he fell on his sword, exclaiming "Axios!" with his dying breath. 'Axios' translates roughly to amen. (Goldsworthy, 2003)
Cato the Younger voluntarily killed himself after the battle of Utica, choosing death over a world ruled by Caesar as attested by Plutarch.
Interestingly, in Tacitus's 'The Agricola' he mentions Agricola shunning the fame his victories as governor of Britain entitled him to. He lived during the reign of Domitian, a famously paranoid emperor, and dared not risk becoming too popular with the masses.
As for your book, if it deals primarily with soldiers judging by the main character being a centurion I do not believe this was a common practice. Scipio Africanus recruited veterans from the Battle of Cannae, one of Rome's biggest military embarrassments, while they were stationed in Sicily as punishment, for his campaign in Africa against Carthage. The defeat at Cannae put Rome in mortal danger from Hannibal's army but the legions did not commit a mass suicide.
The Siege of Masada ended when the army erected a large earthen ramp to storm the mountain top fortress only to find the zealots inside chose mass suicide however, as told in Josephus' 'The Jewish War'.
In both the Republic and Empire it was common for Generals and commander who were being severely defeated to commit suicide rather than be captured. At the Battle of Carrhae Crassus' (the General of the army) son, Publius:
Publius, declaring that no death could have such terrors for him as to make him desert those who were perishing on his account, ordered them to save their own lives, bade them farewell, and dismissed them. Then he himself, being unable to use his hand, which had been pierced through with an arrow, presented his side to his shield-bearer and ordered him to strike home with his sword. (Plutarch, Crassus 25.11.)
This was in 53 BC in battle against the Parthian Empire.
Following defeat at the Battle of Actium, Plutarch describes how Antony fled to and committed suicide in Egypt rather than be captured by Octavian:
Now, Antony had a trusty slave named Eros. Him Antony had long before engaged, in case of need, to kill him, and now demanded the fulfilment of his promise. So Eros drew his sword and held it up as though he would smite his master, but then turned his face away and slew himself. And as he fell at his master's feet Antony said: "Well done, Eros! though thou wast not able to do it thyself, thou teachest me what I must do"; and running himself through the belly he dropped upon the couch. (Plutarch)
Cato, an enemy of Caesar, had his allies defeated at the Battle of Utica but himself did not participate. He stabbed himself with a sword but:
Cato did not immediately die of the wound; but struggling, fell off the bed, and throwing down a little mathematical table that stood by, made such a noise that the servants, hearing it, cried out. And immediately his son and all his friends came into the chamber, where, seeing him lie weltering in his own blood, great part of his bowels out of his body, but himself still alive and able to look at them, they all stood in horror. The physician went to him, and would have put in his bowels, which were not pierced, and sewed up the wound; but Cato, recovering himself, and understanding the intention, thrust away the physician, plucked out his own bowels, and tearing open the wound, immediately expired. (Plutarch)
However these were all leaders who chose their own death over capture and humiliation or torture. As for being ordered to commit suicide over petty matters I can't say I have ever heard of any examples.
As others mentioned, Marc Antony committed suicide when faced with defeat by Octavian Augustus. A somewhat different type of suicide is that of Lucretia, which we hear of in Livy's Rape of Lucretia. In that possibly apocryphal story, Lucretia commits suicide after being raped by the son of the Roman King (not emperor-this story refers to the period before the republic.) Her father's friend, who was there when Lucretia recounted her suicide, subsequently swore to never tolerate kings again.
This story was very well known in Rome and set a standard for (the aristocratic male view of) female sexual chastity. A similar set of stories feature Christian women killing themselves during the reign of Maxentius in Rome when he allegedly tried to rape them; this story was written by Eusebius, a major proponent of Maxentius' rival Constantine, who defeated Maxentius at the Milvian bridge, so its veracity should be questioned. However, it does show that the act of suicide was at one point acceptable in the Christian world in order to defend female chastity, and that this sort of thing was not unheard of. The contrast between these two incidents is interesting as the first suicide occurred after the rape, while the suicide with the Christian woman took place before Maxentius could violate her chastity.