This is from Deities & Demi-Gods page 56
Deities do not have challenge ratings.Entities of this sort are so far above the realm of mortal heroes that determining their level of power in re
Relation to mortals becomes almost meaningless.
After that it also goes on to say...
If you feel the need to calculate a Challange Rating for a deity,try adding its total Hit Dice to its divine rank. The result may or may not be an accurate estimate of what level of characters could Challange this god...
Also for your information a divine rank of 0 is quasi- deity or hero-deities.
A "Demi-God" is divine ranks 1-5 this information is found on page 25 of Deities and Demigods.
So with that said your "Quasi-Deity's" CR would equal the amount of hit dice he or she would have. So if your Quasi-Deity had 20 outsider hit dice as the norm of any deity you would add 20 to the number of class hit dice he would have easily putting him out of reach with a level 18 party.
But as you stated in your question your creature only has 20 hit dice so his "CR" would be 20. No adjustment for the divine rank of 0.
There's no such thing as senseless violence, according to the one who commits it. Characters who kill or torture without at least an internal justification are crazy, not evil. You don't have a reason to kill people in the party or at random, so you don't. This doesn't make you nonevil.
Also remember that just because you're Evil doesn't mean you're a villain. Many Evil characters have no ambitions higher than their own survival and/or comfort; they don't aspire to great power, nor to purge the world of the target of their hate. They're just trying to get by, not so different from the rest of us.
The traditional list of Seven Deadly Sins was originally compiled not so much as a list of inherent sins, but a list of reasons that people sin. This makes it a great source of motives for Evil characters. I prefer to expand the list to nine, adding Fear as Wrath's twin in the fight-or-flight reflex, and Despair because it was actually in the original list; Sloth replaced it later.
Avarice: The key to happiness is having things. I will have it all.
Envy: I deserve it, not them. I will have it from them.
Gluttony: Pity those not at the top of the food chain. I will never be in that position.
Lust: I want to do it all, and I will let nothing get in my way.
Pride: I must be better then them: so much so that my superiority is never even questioned.
Sloth: I just don't want to do it. Let them do it for me. If they refuse, make them do it for me.
Wrath: They will never hurt me again. I will punish them for what they did, and leave them unable to do it to anyone else.
Fear: They must not be allowed to hurt me. (Note the lack of an again here: this is one of the big differentiators between Fear and Wrath, but it can make a huge difference in the character).
Despair: I just want the pain to end. Giving it to others helps.
Also keep in mind that these are core motivations. Any one of them will need to be elaborated upon. What is it? Who are they? How does the character plan to achieve this goal? Also worth noting is the lengths that your character goes to to hide her motives. Evil characters often prey upon one another's weaknesses, and while Wrath-type characters might not worry about seeming weak due to their motives, Sloth-type and Fear-type characters likely would. These folks are likely to construct a facade, often but not always based on Wrath, as a matter of posturing.
Your character sounds like a Wrath-type, with a focus on the undead. Because her main focus is on something that is not so amenable to the survival of humanity in general, she can get along decently well in society, and even be a very useful sort of person to have around. Some might even mistake her for heroic. But she has a twisted fight-or-flight reflex: any slight or injury, real or imagined, runs the risk of touching on that trauma, for reasons that make sense only to your character (if they even make sense to her). She might lash out disproportionately at small threats, or even against things she mistakenly believes to be threats, but are not.
Best Answer
Intelligence Damage
This, combined with the fact that the beetles only have Intelligence 1 suggests an immediate method of control: reduce them to 0 intelligence. Ability damage (as opposed to ability drain) heals naturally at a rate of 1 point per day, which is good and bad: it means you don't need to do anything to "reactivate" the beetles, just wait a day, but it means you'll need to reapply the damage every day.
There are a variety of fairly stupid and complicated methods for inflicting Intelligence damage upon targets, including psionics, summoning certain high-level monsters, and tricking them into reading a vacuous grimoire. But far more easily acquired (both in terms of time and money) is id moss. Id moss is an ingested poison found in the DMG; it costs just 125 gp/dose and deals intelligence damage with a DC 14 Fortitude save. You may wish to use a spell that gives penalties to saving throws (e.g, crushing despair) or just repeatedly apply doses until the creature fails its save. Feed each beetle a dose of id moss with its food each day (for a total cost of 125 gp per beetle per day).
Possible drawback: every time you feed the beetles, you have a 5% chance of accidentally eating a dose of the moss yourself. Keep a cleric on hand to cast neutralise poison and/or lesser restoration.
Cheaper methods
With ten beetles, this does admittedly run you at least 1250 gp/day minimum. There are a few other poisons (most of which affect other stats) that are also possibly usable - but none of them are appreciably cheaper. A different source of poison is clearly required.
Summon Monster I is capable of summoning fiendish monstrous spiders and centipedes for several rounds at 6th level. Spiders have a venom that deals Strength damage; centipedes have one that deals Dexterity damage. On the first day, use id moss or another method of your choice to render the beetles unconscious. Then, summon a spider and a centipede; have the spider and centipede repeatedly bite the unconscious beetles until their Strength and Dexterity scores are also 0. For the initial application you may need to also use a wand of cure light wounds or similiar measures to prevent your spider and centipede from accidentally killing the beetles - they presumably have reasonable Str and Dex scores and so may require many many bites.
Every day from then on, you summon a new spider or centipede and have it bite each beetle down to 0 in Str or Dex respectively. For optimal results, use a spider every even day and a centipede every odd day - this way you can begin biting a beetle to make it Dexterity-drained before the Strength-drain wears off, thus avoiding the risk of the beetle waking up and killing your spider or centipede.