I am confused about the appropriate treatment of stock variables like capital when there is a lag in the production function. For example, in the Dynare guide Y(t) = F(K(t),L(t)) is written in the form Y = F(K(-1),L) in Dynare code, to reflect the fact that capital is a stock and hence predetermined. The production function in my model has the form Y(t)=F(K(t-1),L(t)). Following the logic above, should this be written in Dynare code as Y = F(K(-2),L)?

No. You still code as
y= a*K(-1) + (1-a)*N
In the literature, some people use the y=f(k(-1),N) notation while others use the y=f(k,n) format. either way, they mean that the capital stock is predetermined between any two dates.

What are you trying to do? Traditionally, capital at time t is determined by investment at time t-1 and thus gets the timing (-1) as Reuben said. However, if you want to have that the capital stock determined by investment at t-2 is the one being productive at time t, it should be k(-2) in the production function.

It’ s an OLG model where the young purchase capital so that they can produce output when they are old and have no income. The lag in the production function arises because the amount produced by the current old generation (t) depends on how much capital they purchased in the previous period when young (i.e. purchases at time t-1).

But isn’t this the standard timing? You invest in capital at time t to have it at t+1. In that case, Reuben is correct. There is only a one-period lag as to when new capital can be used.