What's the rule for punctuating quoted words or phrases?

The traditional rule for British English is that punctuation should appear inside the quote marks only if it is part of the quote. So both of your examples would be correct: in the first you are quoting a whole sentence, so include the full stop as part of the quote; in the second you are quoting a single word and the full stop is not part of the quote.

The traditional rule for American English is that the period goes inside the quotes. As is my understanding, the original reason for this was a mechanical limitation of movable type - ending a line with quote-period was less robust than period-quote.

(In either case, where the quote and the surrounding sentence would end with different punctuation marks one is omitted. Usually the more important mark is retained, e.g. keep "?" rather than ".")

However, I don't think this geographical distinction remains entirely accurate for current usage. For example, I know of American cases where a style guide mandates traditional British usage. As long as you choose one and do it consistency, I think either would be generally accepted.