Female octopuses generally lay eggs close to the end of their life span, although some will resorb them. They get squeezed out the ovary, passing through two small glands (oviducal glands) on their way out. Here they get fertilized if the female has mated, and each egg is prepared with a coat to be laid. I've attached an image that shows where the ovary and the dark oviducal glands are located in the female. The photo was taken by Roy Caldwell and I adapted it. The perspective of the ovary is a little off- the ducts and glands are on the left and right sides, not dorsal and ventral, as it looks like in the pic.
Eggs are exuded through the funnel and either (depends on the species):
1) attached singly to a hard surface
2) attached to each other to form a garland, and then attached at the base to a hard substrate, or
3) attached to each other to form a garland, and then carried in the arms.
The female will keep the eggs clean and flushed with water until she dies, which is often right around when the eggs hatch.
Conditions don't need to be any more perfect than the conditions she's been living in so far. If you have a female about to spawn, just make sure the tank has good water flow to keep her and the eggs aeratated. Also- depending on the species, she might be less stressed if she has lots of pebbles and rubble to pile up around her. and/or a good rock to hide in and lay eggs, especially if it has a hole or concave surface big enough to accomodate her, her eggs, and some breathing room.