K-Letter Sayings  | 
Baseball is where this idiom comes from. In baseball, a ball is pitched to the batter. If the batter hits the ball, the other team will, if possible, try to catch the ball before it touches the ground. If they do so, the batter is out. Well, if the batter hits the ball hard enough and it lands in the audience, or in other words he knocks it out of the park, then the other team, their outfielders, have no way to retrieve the ball. Thus, the batter is able to run safely to first, second, and third base and then return back to the home plate (hence a home run). If the batter hit the ball hard enough to do this, then it must have been an exceptional strike, and that's how this phrase is used today, to mean something was done remarkably well.

Alright, the earliest I could find of this saying in print is from the late 19th century. It is indeed being used in relation to baseball, and this example comes from the newspaper Launchestion Examiner, December 1894:

    "The new junior team possesses a splendid hitter in Richards, who managed four times to hit the ball out 
     of the Park."

An alternative way this expression is used is by substituting the word 'knock' with the word 'hit.' Additionally, sometimes 'it' is substituted for 'the ball.' See below for an example.
Meaning:
Origins:
Examples

Knock It Out of The Park - Phrase Meaning and the Idiom's Origin

Something that is done especially well.

Example: As far as cleaning her room goes, Leah really knocked it out of the park. 

Idioms starting with the letter - K.
Phrases and Idioms
* Brian studied hard for an upcoming test, and as a result, he hit the ball out of the park.

* My computer was having all kinds of problems, so I gave it to my brother hoping he could fix it. He gave it back to me hours later, and he certainly knocked it out of the park because it works great!
KnowYourPhrase.com - Common Phrases and Idioms - Meanings and Origins