There are a number of ways to brew with actual coffee:
- Add hot or cold brewed coffee to the beer
- Soak coffee grounds in the beer (usually at flameout, or in secondary)
For both techniques the coffee can be added at various points in the brewing cycle: at the end of the boil, after fermentation has finished, or at bottling/kegging time.
Opinions vary on which method of extraction produces the best flavor. If you add grounds, I'd probably avoid mashing or boiling them and either add them at flameout, or in the fermenter. The advantage to adding them in the fermenter is you can taste the beer until it has the amount of coffee flavor you want, then rack it to another vessel or bottle it. If you brew the coffee, you can add a bit at a time and taste it until you have the amount you want.
I made a coffee porter by cold brewing about 20 oz of coffee (about 1/2 cup of ground coffee soaked in cold water for 36 hours) and adding it with the priming sugar at bottling time. The coffee flavor was noticeable but not overwhelming. Depending on the type of beer, more could be used. Head retention was not affected.