In British style, which is sometimes called logical punctuation, the rule is the same as for question marks and exclamation points: the comma or period goes outside if it is for the whole sentence but inside if it is for just the quoted words. This is called “placement according to sense.”