Littlefinger's plot
Littlefinger plotted to get Ned Stark to King's Landing, as explained in A Storm Of Swords ...
Petyr made Lysa Arryn write the letter, which forced Ned to investigate Jon Arryns death.
Then he used Ned's overly faithful character to turn him against the Lannisters by telling him their little secret. Finally he made sure that the Gold Cloaks would be ready to take him into custody.
Therefore it's mainly Littlefinger's guilt, but there is no evidence (yet), that he actively manipulated Joffrey.
At this time war already begun, Robb Stark was marching south and Jaime Lannister was taken captive, thus starting war couldn't be a reason. Besides that Joffrey was known to be cruel and volatile and didn't need much reason ...
to kill someone as he proved many times.
What about the conversation between Tyrion and Varys?
“Who truly killed Eddard Sark, do you think? Joffrey, who gave the command? Ser Ilyn Payne, who swung the sword? Or… another?”
...
Tyrion cocked his head sideways. “Did you mean to answer your damned riddle, or only to make my head ache worse?”
Varys smiled. “Here, then. Power resides where men believe it resides. No more and no less… A shadow on the wall, yet shadows can kill. And ofttimes a very small man can cast a very large shadow.”
Varys loves philosophical discussion like this one. He's telling that Ned Stark wasn't killed by a single man. Joffrey gave the command, Ilyn Payne executed it, but this all was only possible because most people believe that a king has power. Without that belief soldiers would put down their swords and Joffrey would just be a little kid.
The "small man" he refers to was probably meant to be multiple people. For one Joffrey is only a boy, therefore he's the most likely subject. But as he's talking to "the Imp" it could also be meant to motivate Tyrion.
Interpreting this conversation as proof that Littlefinger put Joffrey up to it, is very far-fetched.
Conclusion
Probably Joffrey just did it out of the blue clear sky.