It depends on what style you're using. If the number in square brackets indicates a superscript number for a footnote, it goes after all punctuation (including any quotation marks). The Chicago Manual of Style recommends that footnote numbers follow all punctuation except a dash.
She said, "It is wrong to write on a Wednesday."2
This is exactly what Lauren Ipsum recommended earlier.
APA style works differently. It indicates citations with parentheses rather than superscript or brackets. Citations go inside the quotation and are are preceded by a space. So:
This is a sentence using an idea taken from someone (2).
If it's a direct quote, things are slightly more tricky. The citation usually follows the quote marks but comes before other punctuation. This may involve removing the punctuation from the end of the quotation so you can add it after the quote.
He said it was "an outrage and a shame" (2).
I'm not 100% sure what you'd do in cases where the quote ends in an exclamation mark or question mark—if, say, the original quote was "This is an outrage and a shame!" I don't see anything in the style guides I've checked (look it up under "direct quotations") but I think I would probably add an extra period.
He said, "This is an outrage and a shame!" (2).