He was physically speaking to the Apostles. It was his of "farewell" to them at the Last Supper. I believe it is Peter who asks Jesus where He is going, Jesus responds that He is going to the Father. Thomas asks Him how they can follow Him there and Jesus responds to them that by knowing Him, they will know the Father. He is telling them that through Him they will reach Heaven. This means that if they have faith in Him, if they know Him, if they love Him, if they follow in His path, they know the Father.