Tip #1: Know how to punctuate
Proper punctuation is so important because it is essentially invisible to the reader. They don't notice it. Mistakes, however, will people the reader out of the story. Since little that is written for school contains dialogue, very people seem to know how to punctuate it correctly. I'm not going to go around dialogue punctuation rules here because on the site linked below, someone else has already spelled it out clearly. If you are unsure of your punctuation, please review the site. Anything the pulls your reader out of the story weakens your work and makes it that much more like they will throw it aside and pick up something new.
Tip #2: Avoid substitutes for "said."
Like proper punctuation, "said" is practically invisible to the reader. Other words to indicate dialogue draw more attention to themselves. If you are going to use a tag other than "said," make sure you have a good reason for doing so and the word you choose comments on how the dialogue was said, such as "whispered" or "shouted." Never use tags other than "said" simply for variety. Words like "added," "announced," "stated," "claimed," etc. draw attention to themselves, and you want to the reader to play attention to your story, not your tags.
Tip #3: Tags can sometimes be left out
While you never want it to be unclear who is speaking, when you have a dialogue between two people, you can tag at the beginning and then simply starting a new paragraph to change speakers will let your reader know who is talking. However, if the dialogue goes on for awhile, you will want occasional tags so that your reader doesn't get lost. Read the following bit of dialogue from The Ghost in Exile:
The Ghost grunted, “Do you have a job for me?”
Zotico’s eyes gleamed. “Do I ever! I’d nearly despaired of finding a capable assassin, but your fortunate arrival proves that Ares will never fail those who serve his name.”
“Who do you want dead?”
“I think it would be best explained by the one in need of Ares’s assistance, but I assure you it is your sort of kill. May I tell the client you’ll meet?”
The Ghost nodded.
Because the speakers were established in the first two lines of dialogue, I don't need tags in the second two lines to make the speaker clear. Pages and pages of this type of dialogue becomes tedious, but sometimes leaving out a tag is good thing.
Tip #4: Indicate speaker with actions rather than tags
Rather than using tags all of the time to indicate speaker, you can include the dialogue in a paragraph where the characters does something. Examine the following dialogue, also from The Ghost in Exile:
Passing an alley, he heard a commotion. He turned to see a young woman pleading with two men. “Don’t make me go with him,” she begged. “He hurts me.” The Ghost recoiled when he heard her Massossinan accent. He hated Massossinans.
The first man slapped her across the face, and The Ghost saw the iron slave collar around the woman’s neck. Her red hair confirmed her nationality. She wore a low-cut, red bodice trimmed with black lace and an extremely short red skirt. She had to be freezing in this weather. “You’ll do as you’re told and like it, or . . .” He drew a knife and ran it across her right breast, drawing a thin line of blood.
The second man grabbed the woman. “You know you like it rough.” He too drew a knife. “Maybe I’ll slice you open when I’m through with you.”
“That will cost you extra,” the first man warned.
The second man shrugged. “I’m good for it."
He imagined his daughter being similarly assaulted. He stepped into the alley. “Let her go.”
The man pulled the woman closer to him. “You can have a turn when I’m done with her.” He grabbed the woman’s breast, and she tried to squirm away. She looked older than he’d thought at first, nearly thirty—old for a whore. Most didn’t live that long.
The Ghost drew his sword and stepped forward. “I said let her go.”
The woman’s master stepped between The Ghost and the other man. “Mister, you have no right to interfere with lawful commerce. She’s mine, and I’ll do with her as I see fit.”
“Not tonight you won't. Move aside.”
It must have been too dark for the man to see the menace in The Ghost’s eyes. Few men dared stand up to him after they’d gotten a good look at the coldness he held there. The slave owner, however, crossed his arms. “Go away.”
You will notice that some of the lines of dialogue are tagged, but many of them simply tell what the character did, such as "grabbed the woman" or "drew his sword." Using action rather than tags creates a more dynamic scene. People generally don't talk in a vacuum. They do something while they are talking.
Tip #5: Use variety (to a point)
Using different ways to indicate the speaker can keep a scene more lively, but getting too creative about tagging calls attention to it. Make sure you have good reasons for what you do in tagging, and don't simply try to be clever. The reader will notice if you do and won't thank you for it.
Keep the above in mind, but remember the only absolute rule in writing is "Does it work?" If it works, a piece of writing can break every rule in the book. Of course, whether or not something works is subjective, so it is better to learn the rules of good writing and only break them when you have a good reason for doing so.