Coffee grounds and coffee filters are good nitrogen sources ('greens') in a compost pile, so add as part of the greens in your compost pile.
Coffee grounds can also be used as a mulch. They are acidic and can be used as a mulch by themselves around evergreens, camellias, and other acid loving plants.
If you have a worm bin of red wigglers, use coffee grounds as worm food. Worms love coffee grounds, and the grounds enhance the texture of the final compost. Tea leaves, tea bags (be sure to remove staples) and coffee filters are also acceptable worm food. Earthworms love coffee grounds too, so using as a mulch and/or in the compost pile is attractive to them as well.