Two things at play here. The first is the usual rules of dialogue, and the second is the rules of dialogue tags.
With tags you usually put a comma between the tag and the dialogue, regardless of if it's before or after the tag. So when you have the tag in the middle you place a comma before and after it. Thus you get:
Fred replied, "Let's go, Tom, as I'm in a hurry to get there."
"Let's go, Tom, as I'm in a hurry to get there," was Fred's reply.
"Let's go, Tom," replied Fred, "as I'm in a hurry to get there."
The above could be turned into 2 short sentences by dropping the as and making the mid-sentence comma a full stop to have:
Fred replied, "Let's go, Tom. I'm in a hurry to get there."
"Let's go, Tom. I'm in a hurry to get there," was Fred's reply.
"Let's go, Tom," replied Fred, "I'm in a hurry to get there."
Based on the usual rules, if you move the dialogue tag from the middle to the ends, or decide you don't need it, then the dialogue's internal punctuation drops back to what is normal for the straight sentence.
Normally the full stop after Tom would be comma due to the replied Fred being part of that sentence as well.