This is a common fear, and the best way to help your child cope is to talk about it -- ideally before the next electrical storm so you can prepare him and help him find ways to cope when it does happen. If your child is over 5 or so, sometimes learning more about what thunder and lightening are and why they happen (as well as how rare it is to get struck) can make your child feel more in control and less afraid. Many experts suggest buying an age-appropriate book for your child and reading it together (so you'll be there to answer her questions), such as Nature's Fireworks: A Book About Lightning by Josepha Sherman.
When you broach the subject of your child's fear, start by validating her feelings. Say something like "I know the sound of thunder and lightening is very scary for you; loud noises often are." Never dismiss or minimize your child's fear; instead, explain that even though lightning can be dangerous, you and your child are safe because you are all indoors or in your car, and away from potential danger zones, like open bodies of water and trees. For toddlers, you can show them that the sounds of thunder and lightning aren't so scary by recreating the noises together with pots and pans. Once they realize they can make that same cracking noise themselves, it won't be such a frightening unknown.
Then during a storm, remind your child why she's safe and put her in control. Ask "what would you like to do to feel better?" Sometimes that means going into another room or building a fort of pillows and crawling into it.