I'm basically going to echo what's already been said, but with a twist.
Yes, of course you can keep talking to the people you're already talking to, on the frequency you're already on. If you're actually talking to someone already, that's probably your best bet, not least because they know you're there.
In fact, especially if you're in controlled airspace, one might argue that speaking up on the radio immediately upon engine failure isn't a horrible idea, if and only if you are able to do so safely. Even a simple "Springfield tower, Cessna '345, pan-pan-pan, engine failure, attempting restart", maybe even while you're pulling out the in-flight engine failure checklist, will give ATC a heads-up that, at the very least, you won't be able to maintain altitude. That would allow them to take your situation into account when vectoring other traffic. If all they see is a VFR GA plane starting to descend, for all they know that's perfectly intentional maneuvering on your part.
Only if you can't reach anyone (who is able to help) on the frequency you're currently on does it make sense to consider fiddling with the radio to switch to 121.5. Fiddling with the radio to change frequency should be well down your mental list of actions to take.
The same reasoning applies to the transponder; you certainly can change to 7700 if you want to and you feel that it is appropriate, but you don't have to. Squawking 7700 will cause your radar return to light up like the proverbial christmas tree at ATC, but saying mayday or possibly declaring emergency is also a pretty good way to get peoples' attention in a hurry.
Once you realize that the engine isn't going to cooperate in restarting, and especially if you realize that you'll be able to make a controlled (but forced) landing on the nearby airport, I'd pretty much just treat it as an ordinary landing, with the caveat of declaring at least pan-pan-pan, possibly mayday, and telling ATC that you have no engine power. Let them deal with the other traffic and just focus on executing a safe landing and vacating the runway as quickly as you are able, but no quicker.
If you realize that the engine isn't going to cooperate, and that you can't make it to the nearest airport, well, that's when a forced outfield landing likely becomes a tempting option. Telling ATC (possibly on 121.5, with the above caveat on whether you're already talking to someone) what your position and intentions are will still allow them to get help out your way in case you do botch the landing. If you do make it down safely, be sure to tell them, relaying via another aircraft if necessary.
Aviate, Navigate, Communicate is a good rule of thumb, but it's a rule of thumb, not dogma. If you're able to communicate while still aviating and navigating, then doing so might help ease at least the burden of navigation.