Solution:
We divide the square in 1×1-squares and color the square in checkerboard fashion such that the corners are black and we call lamps on black and white squares black and white lamps, respectively. We assign the number 1 to a lamp that is on, and the number 0 to a lamp that is off.
If we assign coordinates (0,0) to the lamp in the center, we see that the black lamps are exactly the lamps with the coordinates (i,j) where i+j is even.
Now we assume that the minimum number is 0, that is, there is a configuration where every lamp has an odd number of neighbours that are on, and we try to get a contradiction. For every black lamp with coordinates (i,j),i and j even, we add the numbers associated to its neighbours, and add all these numbers. The parity of this sum S can be determined in the following two ways:
On the one hand, we know that every lamp has an odd number of neighbours with value 1, so we simply have to determine the number modulo 2 of lamps with i and j even. Since we can group lamps at (i,j) with lamps at (−i,−j) and the lamp in the center is the only one left, we get that S is odd.
On the other hand, every white lamp enters the sum as often as it has neighbours with i and j even. But there are exactly two such lamps because exactly one of the coordinates of the white lamp is odd and can be modified with plus or minus 1 to get a neighbour with two even coordinates. There are no problems at the boundary because this process will not change the coordinate ±1008 so we will stay inside the square. Therefore, S is even, which is clearly a contradiction.
So, it is impossible that all lamps have an odd number of neighbours that are on.
Now, we will provide a concrete arrangement where all lamps except for the lamp at the center have an odd number of neighbours that are on.
For the black lamps, i.e. i+j even, we choose the values:
f(i,j)={0, if max(∣i∣,∣j∣)≡0,1mod41, if max(∣i∣,∣j∣)≡2,3mod4
For the white lamps, i.e. i+j odd, we choose the values:
f(i,j)={0, if max(∣i∣,∣j∣−1)≡0,1mod41, if max(∣i∣,∣j∣−1)≡2,3mod4
(This assignment can be found by replacing 2017 with a small number, say 17, starting with a row of zeros, using the assumptions to determine the rest and then notice that the zeros and ones for black or white lamps only form frames of depth 2 around the center.)
It is now easily checked that the condition is satisfied for all non-central lamps:
For a white lamp we assume without loss of generality ∣i∣<∣j∣ (equality is impossible because they have different parity). Then, for the neighbours (i±1,j) and (i,j±1), the bigger coordinates are ∣j−1∣,∣j∣,∣j∣ and ∣j+1∣ and we can check easily that an odd number of them are ≡2,3mod4.
For a black lamp with j>0 or j<0, we argue analogously. If j=0, then i=0 for a non-central lamp, therefore the maximum is ∣i∣ and we have again the values ∣i−1∣,∣i∣,∣i∣, ∣i+1∣ to check which contain an odd number of values ≡0,1mod4.
Therefore, we have found an arrangement with exactly one lamp with an even number of neighbours that are on as desired.

The images show the discussed optimal arrangement for n=77. Lamps that are on are yellow, lamps that are off are blue. The first image shows all lamps, the second image shows the lamps with i+j even and the third image shows the lamps with i+k odd.