Sound and light propagate as waves and are scattered, reflected and change direction when encountering other media and obstacles. By optimizing the spatial placement and distribution of the media, which the waves encounter, one can obtain useful and interesting effects. This thesis describes how topology optimization can be used to design structures for manipulation of the electromagnetic and acoustic waves. The wave problems considered here fall within three classes. The first class concerns the design of cloaks, which when wrapped around an object will render the object undetectable for an outside observer. In the study the material layout of cloaks are restricted to isotropic materials readily available in nature. For fully enclosed, all-dielectric cloaks the cloaking is shown to be nearly perfect for a few discrete angles of incidences in a limited frequency range. The working principle for the cloak is to delay the waves in regions of higher permittivity than the background and subsequently phase match them to the waves outside. Directional acoustic cloaks can also be designed using the topology optimization method. Aluminum cylinders constitutes the design and their placement and size is optimized such that their combined scattering pattern cancel the scattering from a big cylinder. If only the backscattering in a limited angular range needs to be eliminated the electromagnetic cloak design simplifies to surprisingly simple annular Bragg-like grating structures with layer dimensions that depend on the obstacle radius. The second class concerns the optimization of grating couplers for efficient inand out-coupling of electromagnetic surface waves at a metal-dielectric interface. Results indicate that efficiencies beyond 68% are possible for slanted grove-based gratings. The third class concerns the design of planar Fresnel zone plate lenses for focusing electromagnetic waves. The topology optimized zone plates improve the focusing performance compared to results known from the literature.