If PJ wanted to have a sense of danger by the end of the movie, he could have easily done that with the orcs marching to erebor (which was done fantastically IMO). Why did he have to throw away the Lake town attack instead? He could have easily killed two birds with 1 stone by resolving the main arc with the dwarves and lake-town, but still setting up the next film with the dol guldur sub-plot. I don't know why he took the route he did
If PJ wanted to have a sense of danger by the end of the movie
I think you answered your own question. He wanted to end on a cliffhanger, and an angry dragon flying to cause havoc seems limes a pretty good way to do that. The Dol Guldur plot does also end on a cliffhanger it just isn't put at the very end of the film.