There are a few ways:
By far the easiest:
You can stick the gene onto a plasmid and then transform it into bacteria or transfect it into eukaryotes. If the gene has an appropriate promoter its transcription can be activated by other genes.
Usually an antibiotic is used to keep the plasmid within the bacteria or eukaryotic cell, assuming the plasmid confers resistance to that particular antibiotic (if it doesn't, then adding the antibiotic will kill the cells).
-----
Various viruses can also be generated which will express a gene of interest. Often these viruses will quickly kill the cells, so this is used mostly to bulk up protein (google "baculovirus expression" for an example).
Some viruses are crippled so they cannot reproduce and kill cells; this is one of the mechanisms of gene therapy (I think one of them is a crippled form of "adeno-associated virus", but I've never used it).
-----
In the lab I work in at school we use homologous recombination (utilizing "selectable markers" to screen for recombinants) to knock out certain genes. Following knockout of a gene with a selectable marker it is then possible to knock-in a replacement gene and counter-select by looking for transformants which no longer grow in the presence of the selection. PCR with primers flanking the region of interest, and primers internal to the knocked in gene, can be used to verify the gene successfully integrated exactly where you wanted it to.
http://en.wikipedia.org/wiki/Gene_targeting
I'm sure there are more ways of integrating genes, but these are the ones I can think of now.
The big issue in all of them is ensuring that you don't disrupt important parts of the DNA when integrating the foreign DNA. There are various methods to verify this (Southern blots, Inverse-PCR and variants, probably more).
All of this is significantly easier now that the sequences for multiple genomes are available.