It varies depending on what country you are in, but generally speaking, it is simply a question of size and importance - a city is bigger and more important than a town and has more facilities.
In general, the most sensible way to decide whether a place is a city or not is like this:
A city usually has everything that anyone would need in their lives, in terms of their professional, practical and cultural needs. Cities usually have a certain degree of self-government, for example, regarding how money is spent on amenities within the city. A city has enough employment to support the residents of the city, and perhaps also those who come into the city to work from outlying areas. Cities tend to be the business and commercial hub of their region. They have courthouses, major hospitals and so on, are also usually cultural and academic centres, and will have at least one university, and also theatres, perhaps with their own orchestra, as well as large sports stadia and other cultural facilities.
If a place ticks all, or most, of those boxes, you can probably call it a city. If, for example, most people have to go to a larger place to work in a large corporation, make major purchases, or attend university, then you are probably living in a town, rather than a city.