I have heard "Out of town" idiom when people say that they were away.
I wonder why there is no indefinite or definite article before the word 'town'?
IMO, it should be the definite article because I am talking about the particular town.
Chalk it up to idiomatic English. It's curious how we would generally say:
I was out of the area.
I was out of town.
The same goes for the phrase away from:
I was away from the area.
I was away from town.
The same holds true for after we get back:
I'm glad to see you're back in town.
I'm glad to see you're back in the area.
When it comes to the word town, sometimes an article is optional:
I've been looking for you all over town!
I've been looking for you all over the town!
Both of those are acceptable, but I think you'll find the first one is more common and idiomatic.
Interestingly enough, I would never omit the article with the word city:
I was out of the city.
I was away from the city.
I'm glad you made it back to the city.
I've been looking for you all over the city.
There are certain words representing things that are very close to home/self for which we routinely omit a relation that is effectively assumed - the "my" or other personal possessive (esp. "your" if you are telling someone what to do).
So "at home" means "at my home", "at work" means "at my work", "to bed" means "to my bed", "out of town" means "out of my town", "to town" means "to my town" or "to the town (centre) belonging to (of) the suburb (district, city or metropolis) I am in", etc. Similarly "at school", "to uni", "to college".
Note that these represent not just a place, but have a strong implication of function or state - what you do at that place (being safe, sleeping, working, studying). There is a form of metonymy at work here that draws it close to the key functions of life and evokes a whole scene in one word. In French we also have "à table" or "to/at table" but that doesn't make it into English (but maybe the dining/cuisine scene is more important to the French).
The ability to omit the possessive relates to a kind of default that every person (or place) has unless specified otherwise, so a specifier isn't needed. However, when it is in a specific relation to you or part of your body we tend to use "the" (though this is a bit dated in English, but perhaps you'll know the pattern from other European languages). For example we sometimes hear "I need to ask the wife", or it may be "the bullet caught him in the arm/head/toe". But note "He looked him over from head to toe" where which toe isn't important to the metonymy (we aren't just looking at a straight line from the centre of the head to the centre of a particular toe, the reference is literally to the general locus but the metonomy denotes the function of being an extreme, and thus measuring between extremes or scanning everything between the extremes, so we drop the articles).
"I'll put the kettle" on is an example of a similar kind of metonymy where the assumptions you need only one kettle to make the hot tea or coffee you are implicitly offering, it would be redundant to say "fill up MY kettle at MY tap with (MY) water (I'm paying for), put MY kettle on MY hotplate to heat using (MY) electricity (I'm paying for), get down MY tea, wait till MY kettle boils, warm MY pot with (MY) hot water, put (MY) tea in, pour it into (MY) cups, and give you one (of MY cups)".
We are more used to dropping the article with plurals (as with cups) and mass nouns (water/tea) and this extends to a continuum or state (work/sleep), but the reason is basically the same - it is redundant to try to make it definite or to spell out all the obvious possession/ownership/payment knowledge we all share. But this idea of what is obvious or redundant or a standard scenario, is rather culture dependent.
Also, if the preposition is "toward" or "to" it may be elided too to indicate a direction or destination:
So "go home!" = "go to your home!", even "go left" = "go to your left" and "go north" = "go toward the (earth's) north", etc. Though "left" and "north" look like adverbs here they are actually nouns in adverbial phrases of a single word, just like "see you at work Wednesday" (on Woden's day) or "see you at home tomorrow" (originally "on the morrow" or "in the morning", compare German "Morgen" which means both morning and tomorrow).
This takes time to happen and isn't directly productive with new words, and so is more likely to be seen with older words/contexts giving rise to what look like set phrases or collocations.
P.S. Another relevant but technical concept for those interested is entrenchment which explains the "closeness/possession" concept alluded to here - see The Silverstein Hierarchy.
In English, abstract states of being don't generally take articles. For example, there are no articles in expressions like "in good health" or "out of business" or "at sea", because each of these refers to a unique abstract state: there is no other "good health" that the expression might refer to, and while there certainly are many different businesses and seas in the concrete sense, in these expressions the words "business" and "sea" refer to the general abstract concepts that cover all of these different occupations and bodies of water.
Sometimes, as with the expression "at sea" mentioned above, words referring to specific places can also be used in such an abstract manner, to refer to the state of being in any place of that kind, or in the unique relevant place (usually, one's own) of the kind. Thus, for example, while there certainly are billions of different beds in the world, one can say that someone is "in bed" or "out of bed" with no article when referring merely to their state of being in or out of (some; usually their own) bed.
Similar, a person can be "at home" or "at work" regardless of which of the billions of homes or workplaces on the planet they might be at (although the implication is that it's their own). Again, these expressions don't really designate a specific place, but rather a state of being.
It's exactly the same thing with "in town" and "out of town" — these idiomatic expressions don't really refer to specific places, but rather to distinct states of being: If we're both in town, we can meet; if one of us is out of town, we can't, at least not unless we both just happen to be in the same part of the great wide world that exists "out of town". Similarly, you might (especially if you live in a small town where everyone knows everyone else) refer to someone as being "from out of town"; again, there's no need to specify which town, since it's implicit that the expression refers to this town right here.
In effect, the expressions "in town" and "out of town" partition the world into two mutually exclusive regions: this town right here, and the rest of the world (which might have other towns in it, but who cares abut those?). Of course, exactly where the partition line between these two regions lies will depend on the speaker, and possibly on the context of the discussion; but in any context where these phrases might legitimately be used, there is (or shouldn't be) any ambiguity about which town they refer to. Thus, there's no need for an article to indicate that we're talking about this town and not that town, because it's already implicit in the idiom itself.
As Colleen has commented, the phrase is used more to give one's state or status, rather than to refer to one's location. In this sense, it's not really referring to the actual town the person will be out of.
Cancel all my appointments, I'll be out of town next week.
One could analyze this as being similar to other statuses, using other prepositions, such as away from keyboard or out to lunch, or even to more metaphysical statuses such as out of touch or out of sync. But not all statuses omit the: out of my depth, out of my league.
If you use a verb of travel, such as to go, it has more of the locative sense (talking about location):
Cancel all my appointments, I'll be going out of town next week.
But still, we don't use the definite article. It is probably a vestige of Old English, like at home or going home.
Note: English is not consistent about this. One person could say
I'll be out of country all week.
indicating a status, and another could say
I'll be out of the country all week.
which has a locative sense, and uses the definite article.
And few I know will say
I'll be out of county all week.
Probably because most people simply don't need to indicate that they will be out of the county (US states are divided into counties).