There are a number of ways to go. You can add to the boil, add to primary/secondary or add to bottling bucket/keg. I prefer making some cold brew coffee and adding it to my bottling bucket a little at a time until the flavor is right. My last coffee stout I boiled and cooled 2.5 cups of water and added 1/2 cup (4 oz by vol) ground coffee. Left it in the fridge for a day. After filtering the grounds out, that amounted to about 2 cups of cold brew in the bottling bucket, which was just right for 5 gal. The reason to cold brew (i.e. don't put the grounds in hot water) is that hot or boiling water will extract head-killing oils from the coffee. Cold brewing won't.