First, never add rum to a hot pan directly from the bottle unless you want a dramatic (and dangerous) flame. Measure it first, then pour away from the heat source. Second, always taste your rum before cooking—if you wouldn’t drink it, don’t cook with it. Cheap rum can leave a bitter, metallic aftertaste.
Finally, remember that alcohol cooks off at different rates. For maximum flavor, add rum near the end of cooking. For a subtle background note, add it early and let it simmer. And if you want a boozy kick in a dessert, brush the cake with rum after baking, like a Victorian sponge cake gone rogue.