To target something, you must have a clear path to it, so it can't be behind total cover. If you place an area of effect at a point that you can't see and an obstruction, such as a wall, is between you and that point, the point of origin comes into being on the near side of that obstruction.
https://dndbeyond.com/sources/basic-rules/spellcasting#AreasofEffectAreas of Effect
Every area of effect has a point of origin, a location from which the spell's energy erupts.
...
A spell's effect expands in straight lines from the point of origin. If no unblocked straight line extends from the point of origin to a location within the area of effect, that location isn't included in the spell's area.
...
You select a cube's point of origin, which lies anywhere on a face of the cubic effect. The cube's size is expressed as the length of each side."