Both are correct. The traditional view is that the adverb only should be placed next to the word or words whose meaning it restricts: I have seen him only once rather than I have only seen him once . The argument for this, a topic which has occupied grammarians for more than 200 years, is that if only is not placed correctly the scope or emphasis is wrong, and could even result in ambiguity.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.