Abbie1948 is stating the British rule. In standard American usage, you would put the comma inside the quotation marks -- ["] = "inverted commas" in British usage.
The American rule has no logic to it -- it was simply adopted (long ago and indisputably) as a printer's convention because it looked better than [",].