Hello Agata,
In the first sentence
He was working at the restaurant for a month last year
We know which restaurant he was working at 'the' and the connection is to emphasis that he had a job at a particular restaurant for a particular time.
The second sentence
He worked at a restaurant for a month last year.
This is completed action in finished time and we don't know which restaurant. (a restaurant). We are more interested in the completed action rather than detail.