When the opportunity arises, disengage and create distance between you and the attacker. This will give you a chance to retrieve an appropriate use-of-force tool such as a TASER, OC spray, or even a handgun, depending on the level of force required.
Distance also gives you a chance to order the attacker to comply with your verbal orders. Order him to stay down. If the suspect complies, you can get him proned out and order him into a cuffing position. You should not be in a hurry to cuff the suspect. Continue to talk to him, call for backup, and if possible, wait for backup.
Always try to avoid a situation where you could be taken down by a suspect. Awareness of the suspect's demeanor and body language can go a long way toward keeping you out of this situation. As you approach a suspect, keep a safe distance between you and him, position your weapon side away from him, and maintain constant communications with him. All of these measures can prevent you from ending up in the "worst-case scenario" of being on the ground with an attacker on top of you.
Still, you may find yourself in this situation, and you must be able to respond quickly to stay safe. The trap and roll is a very basic jujitsu technique that is effective and simple.
Repetition is the key to becoming proficient at this, or any, technique. Under stress you will resort to what you know and what you have practiced. Learning one technique that can save your life and practicing that technique is recommended over learning numerous techniques for each attack.