The perfect square [tex](x-a)^2[/tex] can be expanded as follows:
[tex](x-a)^2=x^2-2ax+a^2[/tex]
So, we have to think of the term [tex]-8x[/tex] as [tex]-2ax[/tex], which implies [tex]a=4[/tex].
Thus, we have to add [tex]a^2[/tex], i.e. 16, to complete the perfect square:
[tex](x-4)^2 = x^2-8x+16[/tex]