In dialogue, quotation marks go AFTER the period or question mark:
“Did you pick up the things we needed?” Jim said.
“I didn’t have time,” she said.
“You’re kidding. You had four hours!”
“I was writing.” She smiled.
If you forget, just pick up a book or a newspaper to check the format.
Apparently, it’s been done differently in the past in the UK, but I believe it’s pretty much standard now.