This famous piece is from the charming Notebook for Anna Magdalena Bach. But it was probably not written by Johann Sebastian Bach at all! A Wikipedia entry says,
"Most of the entries in the 1725 notebook were made by Anna Magdalena herself, with others written in the hand of Johann Sebastian, some by sons Johann Christian and Carl Philipp Emanuel, and a few by family friends such as Johann Gottfried Bernhard and Johann Gottfried Heinrich.
Although the 1725 notebook does contain work composed by Johann Sebastian Bach, it also includes works by many other composers. The authorship of several pieces is identified in the notebook itself, while that of others was established by researchers. The composers of still others, including several popular songs of the time, remain unknown.
"The Minuet in G major is a keyboard piece included in the Notebook for Anna Magdalena Bach and often attributed to Johann Sebastian Bach, but it is now usually attributed to Christian Petzold. However, even today it is still quite unknown who composed this piece, partly because it was copied anonymously into the Notebook for Anna Magdalena Bach."