Sew slip / ladder stitch on the opening about 1/8″ from the raw edge. Let the thread loose and don’t pull it yet.
After finish slip stitch the opening, pull the thread to close the opening.
With the needle still on the sock, wrap 2 to 3 rounds of thread on it, pull the needle through while pressing the wrapping thread with your finger.
Insert the needle some where near by and come out from the other side. Pull the thread and cut it close to the sock. The thread will be hidden in the sock neatly. Always do this when you sew.