Ad hoc is a Latin phrase meaning literally "for this". In English, it generally signifies a solution designed for a specific problem or task, non-generalizable, and not intended to be able to be adapted to other purposes (compare with a priori).
Common examples are ad hoc committees, and commissions created at the national or international level for a specific task. In other fields, the term could refer, for example, to a military unit created under special circumstances, a tailor-made suit, a handcrafted network protocol (e.g. ad hoc network), a temporary banding together of geographically-linked franchise locations (of a given national brand) to issue advertising coupons, or a purpose-specific equation.
Ad hoc can also be an adjective describing the temporary, provisional, or improvised methods to deal with a particular problem, the tendency of which has given rise to the noun Adhocism. It also could mean shifting contexts to create new meanings or inadequate planning. 
Style guides disagree on whether Latin phrases like ad hoc should be italicized. The trend is to not use italics. For example, The Chicago Manual of Style recommends that familiar Latin phrases that are listed in the Merriam-Webster dictionary, including "ad hoc", not be italicized.
In science and philosophy, ad hoc means the addition of extraneous hypotheses to a theory to save it from being falsified. Ad hoc hypotheses compensate for anomalies not anticipated by the theory in its unmodified form.
In the military, ad hoc units are created during unpredictable situations, when the cooperation between different units is suddenly needed for fast action, or from remnants of previous units which have been overrun or otherwise decimated.
The term "ad hoc networking" typically refers to a system of network elements that combine to form a network requiring little or no planning.